From 1da09f0f14cb309cb06851676a2d5c287c31de97 Mon Sep 17 00:00:00 2001 From: marko-bekhta Date: Tue, 15 Nov 2022 13:16:37 +0100 Subject: [PATCH] HSEARCH-3654 Upgrade Junit where possible --- Jenkinsfile | 4 +- .../cfg/ElasticsearchVersionTest.java | 28 +- ...ntUtilsTryGetElasticsearchVersionTest.java | 107 +++-- .../client/impl/GsonHttpEntityTest.java | 112 +++-- .../impl/ElasticsearchDialectFactoryTest.java | 83 ++-- .../spi/ElasticsearchDialectsTest.java | 43 +- .../gson/spi/GsonClassesTest.java | 14 +- .../gson/spi/GsonParsingTest.java | 40 +- ...ElasticsearchBatchedWorkProcessorTest.java | 21 +- .../ElasticsearchDefaultWorkBulkerTest.java | 23 +- ...csearchDefaultWorkSequenceBuilderTest.java | 37 +- ...csearchIndexIndexingPlanExecutionTest.java | 29 +- .../elasticsearch/work/impl/BulkWorkTest.java | 25 +- .../lucene/cfg/LuceneIndexSettingsTest.java | 6 +- .../index/impl/IndexAccessorTest.java | 57 ++- .../lowlevel/join/impl/ChildDocIdsTest.java | 10 +- .../writer/impl/LoggerInfoStreamTest.java | 24 +- .../impl/LuceneBatchedWorkProcessorTest.java | 35 +- ...ighterPassageFormatterWithEncoderTest.java | 12 +- .../LuceneIndexIndexingPlanExecutionTest.java | 103 +++-- build/config/pom.xml | 8 +- .../src/main/resources/forbidden-internal.txt | 2 + .../checks/regexp/StringSuppressorTest.java | 27 +- build/jqassistant/rules/rules.xml | 7 +- build/parents/build/pom.xml | 19 + build/parents/integrationtest/pom.xml | 2 +- .../documentation/analysis/AnalysisIT.java | 14 +- .../analysis/ElasticsearchAnalysisIT.java | 10 +- .../analysis/LuceneAnalysisIT.java | 14 +- .../client/ElasticsearchGetClientIT.java | 16 +- .../ElasticsearchHttpClientConfigurerIT.java | 16 +- .../client/HttpClientConfigurer.java | 2 +- .../ElasticsearchIndexManagerIT.java | 16 +- .../ElasticsearchCustomLayoutStrategyIT.java | 16 +- .../ElasticsearchCustomIndexMappingIT.java | 16 +- .../ElasticsearchCustomIndexSettingsIT.java | 10 +- .../asnative/ElasticsearchNativeTypeIT.java | 16 +- .../lucene/analyzer/LuceneGetAnalyzerIT.java | 18 +- .../indexmanager/LuceneGetIndexSizeIT.java | 16 +- .../lowlevel/LuceneLowLevelIndexReaderIT.java | 16 +- .../type/asnative/LuceneNativeTypeIT.java | 16 +- .../ElasticsearchConfigurationIT.java | 6 +- .../AlternativeBinderIT.java | 35 +- .../HibernateOrmIndexingPlanFilterIT.java | 22 +- .../bridgeresolver/BridgeResolverIT.java | 16 +- .../DependenciesFromOtherEntityIT.java | 16 +- .../DependenciesContainersPropertyIT.java | 16 +- .../DependenciesContainersSimpleIT.java | 16 +- .../simple/DependenciesSimpleIT.java | 16 +- .../dynamic/DocumentModelDslDynamicIT.java | 16 +- .../dsl/object/DocumentModelDslObjectIT.java | 16 +- .../dsl/simple/DocumentModelDslSimpleIT.java | 16 +- .../IndexFieldTypeDslDslConverterIT.java | 16 +- ...ndexFieldTypeDslProjectionConverterIT.java | 16 +- .../dsl/simple/IndexFieldTypeDslSimpleIT.java | 16 +- .../binder/IdentifierBinderIT.java | 35 +- .../IdentifierBridgeCompatibleIT.java | 16 +- .../IdentifierBridgeOrmContextIT.java | 16 +- .../IdentifierBridgeParamAnnotationIT.java | 16 +- .../string/IdentifierBridgeParamStringIT.java | 16 +- .../simple/IdentifierBridgeSimpleIT.java | 35 +- .../namedpredicate/NamedPredicateIT.java | 16 +- .../PropertyBridgeBridgedElementIT.java | 35 +- .../PropertyBridgeOrmContextIT.java | 16 +- .../PropertyBridgeParamAnnotationIT.java | 35 +- .../string/PropertyBridgeParamStringIT.java | 35 +- .../simple/PropertyBridgeSimpleIT.java | 16 +- .../RoutingBridgeConditionalIndexingIT.java | 35 +- .../ormcontext/RoutingBridgeOrmContextIT.java | 16 +- .../routingkey/RoutingBridgeRoutingKeyIT.java | 35 +- .../ormcontext/TypeBridgeOrmContextIT.java | 16 +- .../TypeBridgeParamAnnotationIT.java | 35 +- .../param/string/TypeBridgeParamStringIT.java | 35 +- .../typebridge/simple/TypeBridgeSimpleIT.java | 16 +- .../binder/ValueBridgeBinderIT.java | 35 +- .../compatible/ValueBridgeCompatibleIT.java | 16 +- .../indexnullas/ValueBridgeIndexNullAsIT.java | 16 +- .../ormcontext/ValueBridgeOrmContextIT.java | 16 +- .../ValueBridgeParamAnnotationIT.java | 16 +- .../string/ValueBridgeParamStringIT.java | 16 +- .../projection/ValueBridgeProjectionIT.java | 16 +- .../simple/ValueBridgeSimpleIT.java | 35 +- .../ContainerExtractorIT.java | 35 +- .../HibernateOrmSimpleMappingIT.java | 41 +- .../HibernateOrmIndexedIT.java | 45 +- .../HibernateOrmEntryPointsIT.java | 26 +- .../GettingStartedCustomAnalysisIT.java | 24 +- .../GettingStartedDefaultAnalysisIT.java | 27 +- ...ettingStartedWithoutHibernateSearchIT.java | 18 +- .../IdentifierMappingCustomTypeIT.java | 16 +- .../IdentifierMappingNaturalIdIT.java | 35 +- .../IndexedEmbeddedExcludePathsIT.java | 16 +- .../FilteredAssociationIT.java | 35 +- ...exedEmbeddedIncludeEmbeddedObjectIdIT.java | 16 +- .../IndexedEmbeddedIncludePathsIT.java | 16 +- ...IndexedEmbeddedIncludePathsAndDepthIT.java | 16 +- .../none/IndexedEmbeddedNoneIT.java | 16 +- .../onelevel/IndexedEmbeddedOneLevelIT.java | 35 +- .../IndexedEmbeddedStructureFlattenedIT.java | 35 +- .../IndexedEmbeddedStructureNestedIT.java | 35 +- .../twolevels/IndexedEmbeddedTwoLevelsIT.java | 16 +- .../SearchMappingIndexedEntitiesIT.java | 20 +- .../AbstractHibernateOrmMassIndexingIT.java | 8 +- ...IndexingPlanSynchronizationStrategyIT.java | 10 +- .../indexing/HibernateOrmJakartaBatchIT.java | 20 +- .../HibernateOrmManualIndexingIT.java | 30 +- .../indexing/HibernateOrmMassIndexerIT.java | 16 +- ...HibernateOrmMassIndexerMultiTenancyIT.java | 18 +- .../simple/ProgrammaticMappingSimpleIT.java | 16 +- .../AssociationInverseSideIT.java | 35 +- .../reindexing/derivedfrom/DerivedFromIT.java | 35 +- .../no/correct/ReindexOnUpdateNoIT.java | 35 +- .../ReindexOnUpdateNoIncorrectIT.java | 16 +- .../correct/ReindexOnUpdateShallowIT.java | 36 +- .../ReindexOnUpdateShallowIncorrectIT.java | 10 +- ...sticsearchHibernateOrmSchemaManagerIT.java | 16 +- .../HibernateOrmSchemaManagerIT.java | 30 +- .../genericfield/GeoPointGenericFieldIT.java | 36 +- .../multiple/GeoPointBindingMultipleIT.java | 16 +- .../property/GeoPointBindingPropertyIT.java | 16 +- .../type/GeoPointBindingTypeIT.java | 35 +- .../StandalonePojoEntryPointsIT.java | 30 +- ...tandalonePojoReadPropertiesFromFileIT.java | 24 +- .../GettingStartedCustomAnalysisIT.java | 24 +- .../GettingStartedDefaultAnalysisIT.java | 27 +- .../loading/StandalonePojoMassLoadingIT.java | 22 +- .../StandalonePojoSelectionLoadingIT.java | 22 +- .../config/MappingConfigurationIT.java | 22 +- .../StandalonePojoMultiTenancyIT.java | 22 +- .../failurehandler/FailureHandlerIT.java | 16 +- .../failurehandler/MyFailureHandler.java | 2 +- .../search/aggregation/AggregationDslIT.java | 22 +- .../ElasticsearchAggregationDslIT.java | 16 +- .../search/converter/DslConverterIT.java | 18 +- .../converter/ProjectionConverterIT.java | 18 +- .../highlighting/HighlightingDslIT.java | 54 +-- .../search/paths/FieldPathsIT.java | 22 +- .../ElasticsearchPredicateDslIT.java | 16 +- .../predicate/LucenePredicateDslIT.java | 16 +- .../search/predicate/PredicateDslIT.java | 68 +-- .../ElasticsearchProjectionDslIT.java | 20 +- .../projection/LuceneProjectionDslIT.java | 18 +- .../search/projection/ProjectionDslIT.java | 44 +- .../search/query/ElasticsearchQueryDslIT.java | 18 +- .../search/query/LuceneQueryDslIT.java | 18 +- .../search/query/QueryDslIT.java | 46 +- .../search/sort/ElasticsearchSortDslIT.java | 16 +- .../search/sort/LuceneSortDslIT.java | 16 +- .../documentation/search/sort/SortDslIT.java | 38 +- .../testsupport/BackendConfigurations.java | 6 +- .../testsupport/DocumentationSetupHelper.java | 85 ++-- .../testsupport/TestConfiguration.java | 2 +- .../ProjectionBinderComposingIT.java | 17 +- ...rojectionBinderConstructorParameterIT.java | 34 +- .../multi/ProjectionBinderMultiIT.java | 33 +- .../ProjectionBinderParamAnnotationIT.java | 34 +- .../string/ProjectionBinderParamStringIT.java | 34 +- .../simple/ProjectionBinderSimpleIT.java | 34 +- .../ProjectionConstructorMappingJava17IT.java | 50 ++- .../projection/ProjectionDslJava17IT.java | 106 +++-- ...tructorObjectProjectionExcludePathsIT.java | 17 +- ...tructorObjectProjectionIncludePathsIT.java | 16 +- ...bjectProjectionIncludePathsAndDepthIT.java | 17 +- .../spi/BatchingExecutorTest.java | 151 +++---- .../orchestration/spi/SingletonTaskTest.java | 6 +- .../FromDocumentFieldValueConverterTest.java | 21 +- .../ToDocumentFieldValueConverterTest.java | 21 +- .../OperationSubmitterExecutorTest.java | 28 +- .../OperationSubmitterQueueTest.java | 18 +- ...lAwareConfigurationPropertySourceTest.java | 16 +- .../engine/cfg/BackendSettingsTest.java | 6 +- .../engine/cfg/ConfigurationProviderTest.java | 20 +- .../search/engine/cfg/IndexSettingsTest.java | 6 +- .../MapConfigurationPropertySourceTest.java | 8 +- ...SystemConfigurationPropertySourceTest.java | 12 +- ...onfigurationPropertyBeanReferenceTest.java | 33 +- ...rationPropertyInvalidSimpleValuesTest.java | 84 ++-- ...urationPropertyValidMissingValuesTest.java | 82 ++-- ...gurationPropertyValidSimpleValuesTest.java | 88 ++-- .../search/engine/cfg/spi/ParseUtilsTest.java | 8 +- .../dsl/impl/DslExtensionStateTest.java | 45 +- .../IndexManagerBuildingStateHolderTest.java | 46 +- .../impl/SearchIntegrationImplTest.java | 25 +- .../bean/impl/BeanResolverImplBaseTest.java | 37 +- .../BeanResolverImplRetrievalBeanTest.java | 25 +- .../BeanResolverImplRetrievalBuiltinTest.java | 27 +- .../BeanResolverImplRetrievalClassTest.java | 27 +- ...nResolverImplRetrievalConstructorTest.java | 23 +- .../building/impl/TreeNestingContextTest.java | 95 ++-- .../FailSafeFailureHandlerWrapperTest.java | 34 +- .../spi/RootFailureCollectorTest.java | 8 +- .../search/engine/spatial/GeoPolygonTest.java | 14 +- integrationtest/backend/elasticsearch/pom.xml | 5 - .../ElasticsearchExtensionIT.java | 106 ++--- .../ElasticsearchAnalysisConfigurerIT.java | 38 +- .../ElasticsearchBootstrapFailureIT.java | 28 +- .../bootstrap/ElasticsearchBootstrapIT.java | 56 +-- .../ElasticsearchClientFactoryImplIT.java | 211 +++++---- .../client/ElasticsearchContentLengthIT.java | 47 +- .../gson/ElasticsearchGsonConcurrencyIT.java | 14 +- ...ElasticsearchIndexLifecycleStrategyIT.java | 14 +- .../ElasticsearchIndexNamingBaseIT.java | 30 +- .../ElasticsearchFieldAttributesIT.java | 22 +- .../mapping/ElasticsearchFieldTypesIT.java | 18 +- .../ElasticsearchTypeNameMappingBaseIT.java | 115 ++--- .../ElasticsearchTypeNameMappingSchemaIT.java | 60 ++- .../ElasticsearchIndexDescriptorIT.java | 22 +- .../ElasticsearchCustomIndexMappingIT.java | 18 +- .../ElasticsearchCustomIndexSettingsIT.java | 20 +- ...chIndexSchemaManagerCreationAliasesIT.java | 70 ++- ...hIndexSchemaManagerCreationAnalyzerIT.java | 50 +-- ...xSchemaManagerCreationCustomMappingIT.java | 55 ++- ...SchemaManagerCreationCustomSettingsIT.java | 72 +-- ...dexSchemaManagerCreationMappingBaseIT.java | 77 ++-- ...anagerCreationMappingFieldTemplatesIT.java | 82 ++-- ...ndexSchemaManagerCreationNormalizerIT.java | 50 +-- ...SchemaManagerCreationOrPreservationIT.java | 55 ++- ...archIndexSchemaManagerDropAndCreateIT.java | 22 +- ...rchIndexSchemaManagerDropIfExistingIT.java | 22 +- ...rchIndexSchemaManagerDynamicMappingIT.java | 76 ++-- ...ticsearchIndexSchemaManagerExporterIT.java | 28 +- ...IndexSchemaManagerInspectionAliasesIT.java | 63 ++- ...searchIndexSchemaManagerStatusCheckIT.java | 98 ++-- ...archIndexSchemaManagerUpdateAliasesIT.java | 32 +- ...rchIndexSchemaManagerUpdateAnalyzerIT.java | 40 +- ...dexSchemaManagerUpdateCustomMappingIT.java | 34 +- ...exSchemaManagerUpdateCustomSettingsIT.java | 40 +- ...IndexSchemaManagerUpdateMappingBaseIT.java | 36 +- ...maManagerUpdateMappingFieldTemplateIT.java | 44 +- ...hIndexSchemaManagerUpdateNormalizerIT.java | 40 +- ...IndexSchemaManagerValidationAliasesIT.java | 95 ++-- ...ndexSchemaManagerValidationAnalyzerIT.java | 143 +++--- ...chemaManagerValidationCustomMappingIT.java | 76 ++-- ...hemaManagerValidationCustomSettingsIT.java | 95 ++-- ...maManagerValidationMappingAttributeIT.java | 336 +++++++------- ...xSchemaManagerValidationMappingBaseIT.java | 122 ++--- ...nagerValidationMappingFieldTemplateIT.java | 133 +++--- ...exSchemaManagerValidationNormalizerIT.java | 62 ++- .../search/ElasticsearchImplicitFieldsIT.java | 24 +- .../ElasticsearchMatchSearchPredicateIT.java | 20 +- .../ElasticsearchShardsFailedExceptionIT.java | 18 +- .../ElasticsearchBoolSearchPredicateIT.java | 26 +- .../query/ElasticsearchSearchQueryIT.java | 87 ++-- ...searchSearchQueryRequestTransformerIT.java | 28 +- .../util/ElasticsearchClientSpy.java | 52 +-- .../util/ElasticsearchClientSubmitCall.java | 2 +- .../util/ElasticsearchTckBackendAccessor.java | 2 +- .../util/ElasticsearchTckBackendHelper.java | 2 +- .../ElasticsearchTckBackendSetupStrategy.java | 4 +- .../util/ElasticsearchTckTestRunner.java | 19 +- ...icsearchBackendWorkExecutorProviderIT.java | 24 +- .../work/ElasticsearchIndexingIT.java | 61 ++- ...ElasticsearchZeroDowntimeReindexingIT.java | 26 +- integrationtest/backend/lucene/pom.xml | 5 - .../backend/lucene/LuceneBackendIT.java | 26 +- .../lucene/LuceneDocumentModelDslIT.java | 18 +- .../backend/lucene/LuceneExtensionIT.java | 94 ++-- .../analysis/LuceneAnalysisConfigurerIT.java | 26 +- .../lucene/analysis/LuceneSimilarityIT.java | 16 +- .../cache/LuceneQueryCacheConfigurerIT.java | 16 +- .../lucene/index/LuceneIndexManagerIT.java | 26 +- ...IndexRestartFromPreviousIntegrationIT.java | 30 +- .../lucene/lifecycle/LuceneCleanupIT.java | 56 ++- .../directory/AbstractBuiltInDirectoryIT.java | 18 +- .../directory/AbstractDirectoryIT.java | 12 +- .../lowlevel/directory/CustomDirectoryIT.java | 16 +- .../LuceneDirectorySettingsPerShardIT.java | 38 +- .../LuceneLocalFileSystemDirectoryIT.java | 31 +- .../directory/LuceneLocalHeapDirectoryIT.java | 11 +- .../lowlevel/directory/MultiDirectoryIT.java | 36 +- .../LuceneIndexReaderRefreshBaseIT.java | 86 ++-- ...eIndexReaderRefreshSettingsPerShardIT.java | 19 +- .../writer/LuceneIndexWriterCommitIT.java | 75 ++-- .../writer/LuceneIndexWriterSettingsIT.java | 16 +- .../LuceneIndexWriterSettingsPerShardIT.java | 20 +- .../mapping/LuceneFieldAttributesIT.java | 22 +- .../lucene/mapping/LuceneFieldTypesIT.java | 20 +- .../LuceneIndexSchemaManagerCreationIT.java | 42 +- ...SchemaManagerCreationOrPreservationIT.java | 51 +-- ...ceneIndexSchemaManagerDropAndCreateIT.java | 14 +- ...eneIndexSchemaManagerDropIfExistingIT.java | 16 +- .../LuceneIndexSchemaManagerValidationIT.java | 16 +- .../search/LuceneBoolSearchPredicateIT.java | 28 +- .../LuceneFloatingPointInfinitySearchIT.java | 26 +- .../search/LuceneMatchSearchPredicateIT.java | 20 +- .../lucene/search/LuceneNoLimitSearchIT.java | 30 +- .../LuceneNormalizeWildcardExpressionsIT.java | 25 +- .../search/LuceneSearchMultiIndexIT.java | 45 +- .../LuceneSearchTopDocsMergeFieldSortIT.java | 133 +++--- .../LuceneSearchTopDocsMergeScoreSortIT.java | 22 +- ...hTopDocsTotalHitCountOnMatchAllDocsIT.java | 20 +- .../sharding/AbstractSettingsPerShardIT.java | 60 +-- .../lucene/sharding/ShardingExplicitIT.java | 6 +- .../util/LuceneIndexContentUtils.java | 2 +- .../util/LuceneTckBackendAccessor.java | 4 +- .../testsupport/util/LuceneTckTestRunner.java | 20 +- .../LuceneBackendWorkExecutorProviderIT.java | 24 +- .../lucene/work/LuceneIndexingNestedIT.java | 24 +- .../backend/tck/ObjectStructureIT.java | 34 +- .../tck/analysis/AnalysisBuiltinIT.java | 74 +-- .../analysis/AnalysisBuiltinOverrideIT.java | 30 +- .../tck/analysis/AnalysisCustomIT.java | 22 +- .../tck/decimalscale/DecimalScaleIT.java | 78 ++-- .../DocumentElementDynamicFieldNameIT.java | 130 +++--- .../DocumentElementFieldReferenceIT.java | 121 ++--- .../DocumentElementMultiValuedIT.java | 194 ++++---- .../DocumentElementStaticFieldNameIT.java | 128 +++--- .../document/IndexSchemaElementFieldIT.java | 28 +- .../IndexSchemaElementFieldTemplateIT.java | 24 +- .../document/IndexSchemaElementTypeIT.java | 20 +- .../backend/tck/dynamic/FieldTemplateIT.java | 156 ++++--- .../tck/dynamic/ObjectFieldTemplateIT.java | 26 +- .../backend/tck/index/IndexManagerIT.java | 20 +- .../tck/indexnull/IndexNullAsValueIT.java | 18 +- .../tck/metamodel/IndexDescriptorIT.java | 28 +- .../tck/metamodel/IndexFieldDescriptorIT.java | 80 ++-- .../IndexObjectFieldTypeDescriptorBaseIT.java | 20 +- .../IndexValueFieldTypeDescriptorBaseIT.java | 107 +++-- ...eFieldTypeDescriptorStringSpecificsIT.java | 22 +- .../tck/multitenancy/MultiTenancyBaseIT.java | 36 +- .../multitenancy/MultiTenancyMismatchIT.java | 24 +- .../tck/search/SearchMultiIndexIT.java | 34 +- .../search/aggregation/AggregationBaseIT.java | 28 +- .../RangeAggregationSpecificsIT.java | 257 ++++++----- .../SingleFieldAggregationBaseIT.java | 162 ++++--- ...eFieldAggregationFilteringSpecificsIT.java | 71 ++- .../SingleFieldAggregationInvalidFieldIT.java | 67 ++- ...ggregationTypeCheckingAndConversionIT.java | 241 +++++----- ...gleFieldAggregationUnsupportedTypesIT.java | 54 +-- .../TermsAggregationSpecificsIT.java | 199 +++++---- .../bool/BooleanSortAndRangePredicateIT.java | 47 +- .../highlight/AbstractHighlighterIT.java | 121 +++-- .../HighlightProjectionTypeIndependentIT.java | 42 +- ...HighlightProjectionUnsupportedTypesIT.java | 48 +- .../HighlightableCombinationsIT.java | 18 +- .../highlight/HighlighterFastVectorIT.java | 28 +- .../search/highlight/HighlighterPlainIT.java | 8 +- .../highlight/HighlighterUnifiedIT.java | 13 +- .../IncompatibleCombinationHighlighterIT.java | 16 +- .../AbstractPredicateArgumentCheckingIT.java | 21 +- ...stractPredicateConfigurableAnalysisIT.java | 18 +- ...AbstractPredicateFieldInObjectFieldIT.java | 71 +-- .../AbstractPredicateFieldScoreIT.java | 162 ++++--- .../AbstractPredicateInObjectFieldIT.java | 130 +++--- .../AbstractPredicateInvalidFieldIT.java | 8 +- .../AbstractPredicateMultiFieldIT.java | 75 ++-- .../AbstractPredicateScaleCheckingIT.java | 6 +- .../predicate/AbstractPredicateScoreIT.java | 61 +-- .../AbstractPredicateSearchableIT.java | 25 +- .../AbstractPredicateSimpleAnalysisIT.java | 12 +- .../AbstractPredicateSingleFieldIT.java | 23 +- ...tPredicateTypeCheckingAndConversionIT.java | 336 +++++++++----- ...ctPredicateTypeCheckingNoConversionIT.java | 117 +++-- .../AbstractPredicateUnsupportedTypeIT.java | 16 +- .../AbstractSpatialWithinPredicateIT.java | 14 +- .../search/predicate/AndPredicateBaseIT.java | 86 ++-- .../predicate/AndPredicateSpecificsIT.java | 38 +- .../search/predicate/BoolPredicateBaseIT.java | 60 +-- .../predicate/BoolPredicateSpecificsIT.java | 86 ++-- .../predicate/ExistsPredicateBaseIT.java | 225 +++++----- .../ExistsPredicateObjectsBaseIT.java | 148 +++--- .../ExistsPredicateObjectsSpecificsIT.java | 46 +- .../predicate/ExistsPredicateSpecificsIT.java | 97 ++-- .../predicate/MatchAllPredicateBaseIT.java | 68 +-- .../MatchAllPredicateSpecificsIT.java | 24 +- .../predicate/MatchIdPredicateBaseIT.java | 70 +-- .../MatchIdPredicateConverterIT.java | 28 +- .../MatchIdPredicateSpecificsIT.java | 36 +- .../MatchNonePredicateSpecificsIT.java | 22 +- .../predicate/MatchPredicateBaseIT.java | 281 +++++------- .../predicate/MatchPredicateFuzzyIT.java | 38 +- .../predicate/NamedPredicateBaseIT.java | 34 +- ...medPredicateMultiIndexCompatibilityIT.java | 24 +- .../predicate/NestedPredicateLegacyIT.java | 32 +- .../predicate/NestedPredicateSpecificsIT.java | 34 +- .../search/predicate/NotPredicateBaseIT.java | 57 ++- .../predicate/NotPredicateSpecificsIT.java | 30 +- .../search/predicate/OrPredicateBaseIT.java | 86 ++-- .../predicate/OrPredicateSpecificsIT.java | 36 +- .../predicate/PhrasePredicateBaseIT.java | 280 +++++------- .../predicate/PhrasePredicateSpecificsIT.java | 26 +- .../PredicateDefinitionContextIT.java | 26 +- .../predicate/RangePredicateBaseIT.java | 274 +++++------- .../predicate/RangePredicateSpecificsIT.java | 300 +++++++------ .../predicate/RegexpPredicateBaseIT.java | 262 +++++------ .../predicate/RegexpPredicateSpecificsIT.java | 34 +- .../search/predicate/SearchPredicateIT.java | 40 +- .../SimpleQueryStringPredicateBaseIT.java | 297 ++++++------ ...SimpleQueryStringPredicateSpecificsIT.java | 46 +- ...atialWithinBoundingBoxPredicateBaseIT.java | 170 +++---- ...WithinBoundingBoxPredicateSpecificsIT.java | 8 +- .../SpatialWithinCirclePredicateBaseIT.java | 204 ++++----- ...atialWithinCirclePredicateSpecificsIT.java | 6 +- .../SpatialWithinPolygonPredicateBaseIT.java | 170 +++---- ...tialWithinPolygonPredicateSpecificsIT.java | 6 +- .../TermsPredicateAnalyzedFieldIT.java | 28 +- .../predicate/TermsPredicateBaseIT.java | 289 +++++------- .../TermsPredicateMultivaluedIT.java | 61 ++- .../predicate/TermsPredicateSpecificsIT.java | 30 +- .../predicate/WildcardPredicateBaseIT.java | 261 +++++------ .../WildcardPredicateSpecificsIT.java | 26 +- .../AbstractCompositeProjectionFromAsIT.java | 43 +- .../AbstractEntityProjectionIT.java | 31 +- .../AbstractEntityReferenceProjectionIT.java | 15 +- ...bstractProjectionInObjectProjectionIT.java | 421 +++++++++++------- .../projection/CompositeProjectionBaseIT.java | 32 +- .../CompositeProjectionSingleStepIT.java | 40 +- .../projection/DistanceProjectionBaseIT.java | 87 ++-- .../DistanceProjectionMultiValuedBaseIT.java | 99 ++-- .../DistanceProjectionSingleValuedBaseIT.java | 118 ++--- ...ProjectionTypeCheckingAndConversionIT.java | 46 +- .../DistanceProjectionTypeIndependentIT.java | 28 +- .../DistanceProjectionUnsupportedTypesIT.java | 47 +- .../search/projection/EntityProjectionIT.java | 26 +- .../EntityReferenceProjectionIT.java | 16 +- .../FieldProjectionAndSortNestedIT.java | 20 +- .../projection/FieldProjectionBaseIT.java | 87 ++-- .../FieldProjectionMultiValuedBaseIT.java | 73 ++- .../FieldProjectionSingleValuedBaseIT.java | 95 ++-- ...ProjectionTypeCheckingAndConversionIT.java | 253 ++++++----- .../FieldProjectionTypeIndependentIT.java | 26 +- .../IdentifierProjectionBaseIT.java | 34 +- .../projection/ObjectProjectionBaseIT.java | 32 +- .../ObjectProjectionSpecificsIT.java | 38 +- .../search/projection/SearchProjectionIT.java | 62 +-- .../UnsupportedNestingProjectionBaseIT.java | 28 +- .../tck/search/query/SearchQueryBaseIT.java | 32 +- .../tck/search/query/SearchQueryFetchIT.java | 48 +- .../query/SearchQueryLoadingOptionsIT.java | 36 +- .../tck/search/query/SearchQueryScrollIT.java | 56 ++- .../SearchQueryScrollResultLoadingIT.java | 35 +- .../tck/search/query/SearchQuerySelectIT.java | 42 +- .../search/query/SearchQueryTimeoutIT.java | 44 +- .../tck/search/sort/CompositeSortIT.java | 34 +- .../tck/search/sort/DistanceSortBaseIT.java | 251 +++++++---- .../sort/DistanceSortDynamicFieldIT.java | 22 +- .../DistanceSortFilteringSpecificsIT.java | 24 +- ...stanceSortTypeCheckingAndConversionIT.java | 42 +- .../sort/DistanceSortUnsupportedTypesIT.java | 47 +- .../tck/search/sort/FieldSortBaseIT.java | 367 +++++++++------ .../search/sort/FieldSortDynamicFieldIT.java | 74 ++- .../sort/FieldSortFilteringSpecificsIT.java | 53 +-- .../sort/FieldSortScaledSpecificsIT.java | 20 +- .../FieldSortTypeCheckingAndConversionIT.java | 199 +++++---- .../sort/FieldSortTypeIndependentIT.java | 24 +- .../sort/FieldSortUnsupportedTypesIT.java | 47 +- .../backend/tck/search/sort/SearchSortIT.java | 40 +- .../DistanceProjectionComplexCasesIT.java | 15 +- .../spatial/DistanceSearchableSortableIT.java | 40 +- .../search/spatial/MultivaluedSpatialIT.java | 20 +- .../AbstractShardingRoutingKeyIT.java | 32 +- .../ShardingDisabledRoutingKeyIT.java | 2 +- .../sharding/ShardingHashDocumentIdIT.java | 28 +- .../sharding/ShardingHashRoutingKeyIT.java | 2 +- .../util/TckBackendSetupStrategy.java | 10 +- .../util/TestedFieldStructure.java | 4 +- .../SearchSetupHelper.java | 163 +++++-- ...stractIndexWorkspaceSimpleOperationIT.java | 14 +- .../backend/tck/work/IndexIndexerIT.java | 67 ++- .../work/IndexIndexerLargeDocumentsIT.java | 26 +- .../backend/tck/work/IndexIndexingPlanIT.java | 95 ++-- .../tck/work/IndexWorkspaceFlushIT.java | 13 +- .../backend/tck/work/IndexWorkspaceIT.java | 36 +- .../work/IndexWorkspaceMergeSegmentsIT.java | 14 +- .../tck/work/IndexWorkspacePurgeIT.java | 12 +- .../tck/work/IndexWorkspaceRefreshIT.java | 16 +- .../tck/work/IndexingFieldTypesIT.java | 65 +-- .../outboxpolling/JavaModulePathIT.java | 18 +- .../service/JavaModulePathIT.java | 18 +- .../orm/lucene/service/JavaModulePathIT.java | 18 +- .../service/JavaModulePathIT.java | 18 +- .../lucene/service/JavaModulePathIT.java | 18 +- .../mapper/orm/cdi/CdiBeanResolutionIT.java | 40 +- ...xtendedBeanManagerBootstrapShutdownIT.java | 40 +- .../orm-coordination-outbox-polling/pom.xml | 5 - .../OutboxPollingDisabledIT.java | 4 +- .../OutboxPollingStrategyPropertyValueIT.java | 4 +- ...lingAutomaticIndexingBackendFailureIT.java | 22 +- ...PollingAutomaticIndexingConcurrencyIT.java | 26 +- ...cIndexingDynamicShardingRebalancingIT.java | 26 +- ...oxPollingAutomaticIndexingEdgeCasesIT.java | 5 +- ...ollingAutomaticIndexingEventSendingIT.java | 4 +- ...tomaticIndexingInvalidConfigurationIT.java | 26 +- ...oxPollingAutomaticIndexingLifecycleIT.java | 24 +- ...ollingAutomaticIndexingMultiTenancyIT.java | 22 +- ...llingAutomaticIndexingOutOfOrderIdsIT.java | 30 +- ...ingAutomaticIndexingProcessingOrderIT.java | 30 +- ...tboxPollingAutomaticIndexingRoutingIT.java | 22 +- ...ollingAutomaticIndexingShardingBaseIT.java | 77 ++-- ...icShardingIncompatibleConfigurationIT.java | 22 +- ...gStaticShardingInvalidConfigurationIT.java | 28 +- ...cIndexingStaticShardingUnevenShardsIT.java | 28 +- ...gAutomaticIndexingWhileMassIndexingIT.java | 18 +- .../OutboxPollingIndexingPlanFilterIT.java | 6 +- .../mapping/AbortedEventsGenerator.java | 2 +- .../mapping/OutboxPollingSearchMappingIT.java | 30 +- ...boxPollingSearchMappingMultiTenancyIT.java | 117 ++--- ...tomEntityMappingDatabaseColumnTypesIT.java | 22 +- .../OutboxPollingCustomEntityMappingIT.java | 54 +-- .../util/OutboxPollingOrmTestRunner.java | 17 +- .../PerSessionFactoryIndexingCountHelper.java | 2 +- .../mapper/orm/envers/EnversIT.java | 24 +- .../component/EntityReaderComponentIT.java | 7 +- ...rnateSearchPartitionMapperComponentIT.java | 13 +- .../component/ValidationUtilComponentIT.java | 15 +- .../massindexing/BatchIndexingJobIT.java | 86 ++-- .../EntityManagerFactoryRetrievalIT.java | 36 +- .../batch/massindexing/RestartChunkIT.java | 14 +- .../batch/util/BackendConfigurations.java | 4 +- .../batch/util/PersistenceUnitTestUtil.java | 2 +- .../mapper/orm-realbackend/pom.xml | 9 +- ...ectMultipleBackendTypesInClasspathIT.java} | 40 +- ...oDetectSingleBackendTypeInClasspathIT.java | 14 +- .../bootstrap/BeanResolutionIT.java | 22 +- ...tectMultipleBackendTypesInClasspathIT.java | 22 + ...tectMultipleBackendTypesInClasspathIT.java | 21 + .../ConcurrentEmbeddedUpdateLimitationIT.java | 12 +- .../MassIndexingManualSchemaManagementIT.java | 26 +- .../massindexing/MassIndexingMonitorIT.java | 20 +- .../RealBackendDatabaseMultitenancyIT.java | 14 +- .../RoutingBridgeConditionalIndexingIT.java | 16 +- .../routing/RoutingBridgeRoutingKeyIT.java | 16 +- .../ElasticsearchSchemaManagerExporterIT.java | 18 +- .../LuceneSchemaManagerExporterIT.java | 18 +- .../realbackend/sync/OutOfSyncIndexIT.java | 16 +- .../testsupport/BackendConfigurations.java | 6 +- .../NonRepackagedApplicationIT.java | 9 +- .../application/RepackagedApplicationIT.java | 16 +- .../SpringBeanResolutionIT.java | 28 +- .../spring/jta/JtaAndSpringIT.java | 30 +- .../spring/jta/JtaAndSpringMoreComplexIT.java | 32 +- ...dSpringOutboxApplicationConfiguration.java | 2 +- .../spring/jta/JtaAndSpringOutboxIT.java | 30 +- .../RaisedTimeoutJtaAndSpringOutboxIT.java | 24 +- ...ransactionTimeoutJtaAndSpringOutboxIT.java | 18 +- .../spring/outbox/TransactionOutboxIT.java | 18 +- .../spring/sessionproxy/SessionProxyIT.java | 32 +- .../testsupport/AbstractSpringITConfig.java | 4 +- .../spring/transaction/TransactionIT.java | 20 +- integrationtest/mapper/orm/pom.xml | 5 - .../AbstractIndexingPlanFilterIT.java | 41 +- .../ApplicationIndexingPlanFilterIT.java | 67 +-- .../AutomaticIndexingBasicIT.java | 4 +- ...ncurrentModificationInDifferentTypeIT.java | 4 +- ...ingConcurrentModificationInSameTypeIT.java | 4 +- .../AutomaticIndexingDirtyCheckIT.java | 24 +- .../AutomaticIndexingElementCollectionIT.java | 4 +- .../AutomaticIndexingEmbeddableIT.java | 4 +- .../AutomaticIndexingEnabledIT.java | 79 ++-- .../AutomaticIndexingMappedSuperclassIT.java | 4 +- .../AutomaticIndexingMultiTenancyIT.java | 16 +- ...omaticIndexingNonEntityIdDocumentIdIT.java | 4 +- .../AutomaticIndexingOverReindexingIT.java | 4 +- ...ingRoutingBridgeConditionalIndexingIT.java | 4 +- ...aticIndexingRoutingBridgeRoutingKeyIT.java | 4 +- .../SessionIndexingPlanFilterIT.java | 131 +++--- .../AbstractAutomaticIndexingArrayIT.java | 4 +- ...utomaticIndexingAssociationDeletionIT.java | 4 +- ...dexingGenericPolymorphicAssociationIT.java | 6 +- ...ngPolymorphicInverseSideAssociationIT.java | 6 +- ...gPolymorphicOriginalSideAssociationIT.java | 4 +- ...actAutomaticIndexingAssociationBaseIT.java | 4 +- .../AbstractAutomaticIndexingBridgeIT.java | 26 +- ...gBridgeExplicitReindexingFunctionalIT.java | 22 +- .../AutomaticIndexingEmbeddedBridgeIT.java | 22 +- ...edInThroughNonContainingIndexedTypeIT.java | 22 +- ...UnnecessaryCollectionInitializationIT.java | 39 +- ...ingProcessorProxiedAssociatedEntityIT.java | 4 +- ...xingResolverProxiedAssociatedEntityIT.java | 4 +- .../AutomaticIndexingIdentiferRollbackIT.java | 4 +- .../AutomaticIndexingOutOfTransactionIT.java | 4 +- .../AutomaticIndexingSessionFlushIT.java | 8 +- ...aticIndexingSynchronizationStrategyIT.java | 54 +-- .../session/FlushClearEvictAllIT.java | 26 +- ...IndexingPlanSynchronizationStrategyIT.java | 54 +-- .../orm/bootstrap/BootstrapFailureIT.java | 16 +- .../mapper/orm/bootstrap/BootstrapLogsIT.java | 24 +- .../bootstrap/ConfigurationProviderIT.java | 16 +- .../HibernateOrmIntegrationBooterIT.java | 30 +- .../orm/bootstrap/ObsoletePropertiesIT.java | 16 +- .../orm/bootstrap/ShutdownFailureIT.java | 20 +- .../orm/bootstrap/UnusedPropertiesIT.java | 24 +- .../orm/dynamicmap/DynamicMapBaseIT.java | 52 +-- .../ToHibernateOrmQueryIT.java | 6 +- .../ToHibernateOrmScrollableResultsIT.java | 6 +- .../ToHibernateOrmSessionIT.java | 6 +- .../ToJpaEntityManagerIT.java | 4 +- .../orm/hibernateormapis/ToJpaQueryIT.java | 6 +- .../ToSearchSessionFromSessionProxyIT.java | 17 +- .../mapper/orm/mapping/SearchMappingIT.java | 7 +- .../SearchMappingNoDefaultBackendIT.java | 7 +- .../AnnotationMappingDiscoveryIT.java | 18 +- ...HibernateOrmSearchMappingConfigurerIT.java | 20 +- .../AbstractMassIndexingErrorIT.java | 36 +- .../AbstractMassIndexingFailureIT.java | 40 +- .../orm/massindexing/MassIndexingBaseIT.java | 4 +- .../massindexing/MassIndexingCachingIT.java | 4 +- .../MassIndexingComplexHierarchyIT.java | 4 +- .../MassIndexingConditionalExpressionsIT.java | 6 +- .../MassIndexingEmbeddedIdIT.java | 22 +- ...ErrorCustomBackgroundFailureHandlerIT.java | 11 +- ...rorCustomMassIndexingFailureHandlerIT.java | 11 +- ...rrorDefaultBackgroundFailureHandlerIT.java | 6 +- ...ilureCustomBackgroundFailureHandlerIT.java | 17 +- ...ureCustomMassIndexingFailureHandlerIT.java | 16 +- ...lureDefaultBackgroundFailureHandlerIT.java | 6 +- .../massindexing/MassIndexingIdClassIT.java | 4 +- .../MassIndexingInterruptionIT.java | 32 +- .../massindexing/MassIndexingMonitorIT.java | 22 +- .../MassIndexingNonEntityIdDocumentIdIT.java | 22 +- .../MassIndexingPrimitiveIdIT.java | 22 +- .../model/AnnotationMappingAccessTypeIT.java | 24 +- .../mapper/orm/model/BackRefPropertyIT.java | 16 +- .../BindingUsingPropertyMarkerAccessIT.java | 63 ++- .../orm/model/BytecodeEnhancementIT.java | 32 +- .../model/DefaultDecimalScaleMappingIT.java | 20 +- .../orm/model/FilteredAssociationIT.java | 16 +- .../mapper/orm/model/GenericPropertyIT.java | 22 +- .../mapper/orm/model/IdClassIT.java | 20 +- .../orm/model/IdDerivedFromAssociationIT.java | 20 +- .../mapper/orm/model/JpaIdAsDocumentIdIT.java | 16 +- .../mapper/orm/model/MappedSuperclassIT.java | 22 +- .../ProgrammaticMappingAccessTypeIT.java | 24 +- .../orm/model/PropertyInheritanceIT.java | 22 +- .../mapper/orm/model/ProxyIT.java | 22 +- .../mapper/orm/model/SyntheticPropertyIT.java | 16 +- .../mapper/orm/model/TransientPropertyIT.java | 20 +- .../multitenancy/DatabaseMultitenancyIT.java | 30 +- ...tSearchSchemaManagerSimpleOperationIT.java | 6 +- .../SearchSchemaManagerCreateIfMissingIT.java | 2 +- .../SearchSchemaManagerCreateOrUpdateIT.java | 2 +- ...SearchSchemaManagerCreateOrValidateIT.java | 2 +- .../SearchSchemaManagerDropAndCreateIT.java | 2 +- .../SearchSchemaManagerDropIfExistingIT.java | 2 +- .../SearchSchemaManagerValidateIT.java | 2 +- .../AbstractSchemaManagementStrategyIT.java | 22 +- ...tSchemaManagementStrategyValidatingIT.java | 8 +- .../SchemaManagementStrategyCreateIT.java | 2 +- ...emaManagementStrategyCreateOrUpdateIT.java | 2 +- ...aManagementStrategyCreateOrValidateIT.java | 2 +- ...agementStrategyDropAndCreateAndDropIT.java | 16 +- ...hemaManagementStrategyDropAndCreateIT.java | 2 +- .../SchemaManagementStrategyNoneIT.java | 16 +- .../SchemaManagementStrategyValidateIT.java | 2 +- .../mapper/orm/scope/ScopeExtensionIT.java | 22 +- .../mapper/orm/search/SearchQueryBaseIT.java | 6 +- .../AbstractSearchQueryEntityLoadingIT.java | 4 +- ...tSearchQueryEntityLoadingSingleTypeIT.java | 8 +- .../SearchQueryEntityChangingScrollingIT.java | 24 +- .../SearchQueryEntityLoadingBaseIT.java | 5 +- ...SearchQueryEntityLoadingCacheLookupIT.java | 9 +- .../SearchQueryEntityLoadingFetchSizeIT.java | 71 +-- .../SearchQueryEntityLoadingGraphIT.java | 5 +- ...archQueryEntityLoadingMultipleTypesIT.java | 5 +- ...eryEntityLoadingNonUniqueDocumentIdIT.java | 24 +- .../SearchQueryEntityLoadingScrollingIT.java | 2 +- .../orm/session/SearchIndexingPlanBaseIT.java | 7 +- ...chIndexingPlanNonEntityIdDocumentIdIT.java | 4 +- ...rchIndexingPlanPersistBatchIndexingIT.java | 5 +- .../orm/smoke/AnnotationMappingSmokeIT.java | 6 +- .../orm/smoke/ProgrammaticMappingSmokeIT.java | 6 +- .../orm/spi/DifferentSessionFactoriesIT.java | 22 +- ...tractSearchWorkspaceSimpleOperationIT.java | 7 +- .../orm/workspace/SearchWorkspaceFlushIT.java | 2 +- .../SearchWorkspaceMergeSegmentsIT.java | 2 +- .../workspace/SearchWorkspacePurgeBaseIT.java | 2 +- .../SearchWorkspacePurgeRoutingKeyIT.java | 2 +- .../workspace/SearchWorkspaceRefreshIT.java | 2 +- .../orm/model/IndexedEmbeddedRecordIT.java | 26 +- .../DefaultReindexOnUpdateIT.java | 26 +- ...ingPropertiesInSearchMappingBuilderIT.java | 20 +- .../pojo/bootstrap/FailureReportIT.java | 26 +- .../mapper/pojo/lifecycle/CleanupIT.java | 231 +++++----- .../loading/LoadingStrategyInheritanceIT.java | 26 +- .../IncorrectPropertyNameObjectPathIT.java | 16 +- .../mapper/pojo/mapping/SearchMappingIT.java | 52 +-- .../SearchMappingNoDefaultBackendIT.java | 29 +- .../alternative/AlternativeBinderIT.java | 20 +- ...tomConstructorMappingAnnotationBaseIT.java | 32 +- ...ethodParameterMappingAnnotationBaseIT.java | 32 +- ...CustomPropertyMappingAnnotationBaseIT.java | 24 +- .../CustomTypeMappingAnnotationBaseIT.java | 24 +- .../AbstractFieldContainerExtractorIT.java | 66 +-- .../AbstractProjectionConstructorIT.java | 10 +- .../AnnotationMappingDiscoveryIT.java | 18 +- .../pojo/mapping/definition/DependencyIT.java | 40 +- .../definition/DependencyRepeatableIT.java | 18 +- .../mapping/definition/DocumentIdBaseIT.java | 44 +- .../DocumentIdDefaultBridgeAdditionIT.java | 20 +- .../DocumentIdDefaultBridgeBaseIT.java | 76 ++-- .../DocumentIdDefaultBridgeOverridingIT.java | 89 ++-- .../pojo/mapping/definition/FieldBaseIT.java | 34 +- .../FieldContainerExtractorBaseIT.java | 24 +- .../FieldContainerExtractorExplicitIT.java | 10 +- .../FieldContainerExtractorImplicitIT.java | 2 +- .../FieldDefaultBridgeAdditionIT.java | 20 +- .../definition/FieldDefaultBridgeBaseIT.java | 86 ++-- .../FieldDefaultBridgeOverridingIT.java | 82 ++-- .../mapping/definition/FullTextFieldIT.java | 52 +-- .../mapping/definition/GenericFieldIT.java | 40 +- .../definition/IndexNullAsErrorIT.java | 44 +- .../IndexNullAsOnNumericContainerIT.java | 16 +- .../mapping/definition/IndexedBaseIT.java | 62 +-- .../definition/IndexedEmbeddedBaseIT.java | 131 +++--- .../definition/IndexedEmbeddedCycleIT.java | 46 +- .../definition/IndexedEmbeddedDepthIT.java | 16 +- .../mapping/definition/KeywordFieldIT.java | 44 +- .../definition/MarkerBindingBaseIT.java | 18 +- .../definition/NonStandardFieldIT.java | 28 +- ...joStandaloneSearchMappingConfigurerIT.java | 20 +- .../ProjectionConstructorBaseIT.java | 38 +- ...ctionConstructorCompositeProjectionIT.java | 16 +- ...structorDocumentReferenceProjectionIT.java | 14 +- ...ojectionConstructorEntityProjectionIT.java | 20 +- ...onstructorEntityReferenceProjectionIT.java | 14 +- ...rojectionConstructorFieldProjectionIT.java | 32 +- ...ctionConstructorHighlightProjectionIT.java | 28 +- .../ProjectionConstructorIdProjectionIT.java | 14 +- .../ProjectionConstructorInnerInferredIT.java | 30 +- ...ionConstructorObjectProjectionCycleIT.java | 20 +- ...ojectionConstructorObjectProjectionIT.java | 32 +- ...jectionConstructorProjectionBindingIT.java | 28 +- ...rojectionConstructorScoreProjectionIT.java | 16 +- .../definition/PropertyBindingBaseIT.java | 26 +- .../definition/PropertyBridgeBaseIT.java | 63 ++- ...opertyBridgeRuntimePolymorphismHackIT.java | 16 +- .../definition/RoutingBridgeBaseIT.java | 44 +- .../definition/ScaledNumberFieldIT.java | 44 +- .../mapping/definition/TypeBindingBaseIT.java | 26 +- .../mapping/definition/TypeBridgeBaseIT.java | 59 ++- .../TypeBridgeRuntimePolymorphismHackIT.java | 16 +- .../AbstractMassIndexingErrorIT.java | 40 +- .../AbstractMassIndexingFailureIT.java | 46 +- .../pojo/massindexing/MassIndexingBaseIT.java | 34 +- .../MassIndexingComplexHierarchyIT.java | 28 +- .../MassIndexingEnvironmentIT.java | 26 +- ...ErrorCustomBackgroundFailureHandlerIT.java | 13 +- ...rorCustomMassIndexingFailureHandlerIT.java | 13 +- ...rrorDefaultBackgroundFailureHandlerIT.java | 8 +- ...ilureCustomBackgroundFailureHandlerIT.java | 18 +- ...ureCustomMassIndexingFailureHandlerIT.java | 19 +- ...lureDefaultBackgroundFailureHandlerIT.java | 8 +- ...sIndexingIncludedEntityMapHierarchyIT.java | 38 +- .../MassIndexingInterruptionIT.java | 32 +- .../massindexing/MassIndexingMonitorIT.java | 22 +- .../MassIndexingPrimitiveIdIT.java | 22 +- .../pojo/model/AbstractInterfaceIT.java | 22 +- .../model/AnnotationMappingAccessTypeIT.java | 22 +- .../mapper/pojo/model/DuplicateGetterIT.java | 22 +- .../mapper/pojo/model/GenericPropertyIT.java | 22 +- .../pojo/model/ImplementedInterfaceIT.java | 22 +- .../ProgrammaticMappingAccessTypeIT.java | 22 +- .../pojo/model/PropertyInheritanceIT.java | 22 +- .../mapper/pojo/providedid/ProvidedIdIT.java | 22 +- ...tSearchSchemaManagerSimpleOperationIT.java | 32 +- ...emaManagerValidatingSimpleOperationIT.java | 8 +- .../SearchSchemaManagerCreateIfMissingIT.java | 4 +- .../SearchSchemaManagerCreateOrUpdateIT.java | 4 +- ...SearchSchemaManagerCreateOrValidateIT.java | 4 +- .../SearchSchemaManagerDropAndCreateIT.java | 4 +- .../SearchSchemaManagerDropIfExistingIT.java | 4 +- .../SearchSchemaManagerValidateIT.java | 4 +- .../AbstractSchemaManagementStrategyIT.java | 22 +- ...tSchemaManagementStrategyValidatingIT.java | 8 +- .../SchemaManagementStrategyCreateIT.java | 4 +- ...emaManagementStrategyCreateOrUpdateIT.java | 4 +- ...aManagementStrategyCreateOrValidateIT.java | 4 +- .../SchemaManagementStrategyDefaultIT.java | 2 +- ...agementStrategyDropAndCreateAndDropIT.java | 10 +- ...hemaManagementStrategyDropAndCreateIT.java | 4 +- .../SchemaManagementStrategyNoneIT.java | 16 +- .../SchemaManagementStrategyValidateIT.java | 4 +- .../mapper/pojo/scope/ScopeExtensionIT.java | 22 +- .../mapper/pojo/search/SearchQueryBaseIT.java | 28 +- .../AbstractSearchQueryEntityLoadingIT.java | 12 +- ...tSearchQueryEntityLoadingSingleTypeIT.java | 6 +- .../SearchQueryEntityLoadingBaseIT.java | 8 +- ...dingFallbackToProjectionConstructorIT.java | 24 +- ...archQueryEntityLoadingMultipleTypesIT.java | 24 +- .../SearchQueryEntityLoadingScrollingIT.java | 4 +- .../pojo/smoke/AnnotationMappingSmokeIT.java | 30 +- .../smoke/ProgrammaticMappingSmokeIT.java | 30 +- .../AnnotationMappingGeoPointBindingIT.java | 22 +- .../ProgrammaticMappingGeoPointBindingIT.java | 22 +- .../JavaNetURLPropertyTypeDescriptor.java | 2 +- .../util/CloseCountingBeanHolder.java | 2 +- .../testsupport/util/StartupStubBridge.java | 2 +- .../util/StartupStubContainerExtractor.java | 2 +- .../mapper/pojo/timeout/SearchTimeoutIT.java | 26 +- .../pojo/work/PojoIndexingPlanBaseIT.java | 44 +- ...IndexingPlanSynchronizationStrategyIT.java | 22 +- ...actPojoIndexerAddOrUpdateNullEntityIT.java | 13 +- ...AbstractPojoIndexerDeleteNullEntityIT.java | 50 ++- .../AbstractPojoIndexerOperationBaseIT.java | 87 +++- .../AbstractPojoIndexingOperationIT.java | 62 ++- ...stractPojoIndexingPlanOperationBaseIT.java | 101 +++-- ...ingPlanOperationContainedNullEntityIT.java | 50 ++- ...PojoIndexingPlanOperationNullEntityIT.java | 86 +++- ...bstractPojoIndexingProcessorFailureIT.java | 36 +- ...ractPojoReindexingResolutionFailureIT.java | 36 +- .../operations/BackendIndexingOperation.java | 2 +- .../work/operations/PojoIndexingAddIT.java | 23 +- .../operations/PojoIndexingAddOrUpdateIT.java | 23 +- ...xingAddOrUpdateOrDeleteEntityAbsentIT.java | 12 +- ...ingAddOrUpdateOrDeleteEntityPresentIT.java | 12 +- .../work/operations/PojoIndexingDeleteIT.java | 19 +- ...tractSearchWorkspaceSimpleOperationIT.java | 36 +- .../workspace/SearchWorkspaceFlushIT.java | 4 +- .../SearchWorkspaceMergeSegmentsIT.java | 4 +- .../workspace/SearchWorkspacePurgeBaseIT.java | 4 +- .../SearchWorkspacePurgeRoutingKeyIT.java | 4 +- .../workspace/SearchWorkspaceRefreshIT.java | 4 +- ...ructorClassNoParametersCompilerFlagIT.java | 21 +- ...uctorRecordNoParametersCompilerFlagIT.java | 21 +- .../ProjectionConstructorRecordIT.java | 30 +- .../pojo/model/IndexedEmbeddedRecordIT.java | 28 +- .../realbackend/EntityAsGraphSmokeIT.java | 16 +- .../realbackend/EntityAsTreeSmokeIT.java | 16 +- .../mapping/DecimalScaleMappingIT.java | 12 +- .../ElasticsearchSchemaManagerExporterIT.java | 40 +- .../LuceneSchemaManagerExporterIT.java | 18 +- .../testsupport/BackendConfigurations.java | 4 +- .../dataset/SimpleDataSampleParserTest.java | 6 +- .../backend/elasticsearch/SmokeIT.java | 18 +- .../performance/backend/lucene/SmokeIT.java | 6 +- .../LibraryShowcaseMassIndexingIT.java | 21 +- .../library/LibraryShowcaseSearchIT.java | 65 +-- .../showcase/library/Java17IT.java | 23 +- .../v5migrationhelper/engine/pom.xml | 22 + .../junit/SearchFactoryHolder.java | 10 +- .../V5MigrationHelperEngineSetupHelper.java | 6 +- integrationtest/v5migrationhelper/orm/pom.xml | 22 + .../search/test/query/facet/Fruit.java | 2 +- .../test/query/initandlookup/Kernel.java | 2 +- .../SecondLCAndPCLookupTest.java | 2 +- .../query/initandlookup/StrictKernel.java | 2 +- .../StrictSecondLCAndPCLookupTest.java | 2 +- .../testsupport}/StaticIndexingSwitch.java | 2 +- .../V5MigrationHelperJPASetupHelper.java | 33 +- .../V5MigrationHelperOrmSetupHelper.java | 33 +- .../test/util/FullTextSessionBuilder.java | 9 +- ...ateOrmMapperOutboxPollingSettingsTest.java | 6 +- ...ractEventProcessorClusterLinkBaseTest.java | 42 +- ...AbstractEventProcessorClusterLinkTest.java | 23 +- ...ctMassIndexerAgentClusterLinkBaseTest.java | 50 +-- ...stractMassIndexerAgentClusterLinkTest.java | 23 +- ...sorClusterLinkDynamicShardingBaseTest.java | 29 +- ...tProcessorClusterLinkLeaveClusterTest.java | 10 +- ...ixedSharding4ShardSelfDynamicBaseTest.java | 13 +- ...MixedSharding4ShardSelfStaticBaseTest.java | 15 +- ...usterLinkStaticSharding4ShardBaseTest.java | 15 +- ...lusterLinkStaticShardingEdgeCasesTest.java | 30 +- ...entClusterLinkDynamicShardingBaseTest.java | 15 +- ...dexerAgentClusterLinkLeaveClusterTest.java | 10 +- ...usterLinkStaticSharding3ShardBaseTest.java | 15 +- ...nateOrmMapperOutboxPollingClassesTest.java | 14 +- .../MassIndexingJobParametersBuilderTest.java | 148 +++--- .../util/impl/SerializationUtilTest.java | 26 +- .../mapper/orm/HibernateOrmExtensionTest.java | 33 +- ...IntrospectorPerReflectionStrategyTest.java | 27 +- ...rmBootstrapIntrospectorAccessTypeTest.java | 125 +++--- ...trapIntrospectorAnnotationReadingTest.java | 22 +- .../impl/PojoAssociationPathInverterTest.java | 17 +- .../spi/BuiltinAnnotationsTest.java | 14 +- .../pojo/model/path/PojoModelPathTest.java | 30 +- .../impl/TypePatternMatcherFactoryTest.java | 52 +-- pom.xml | 18 - .../data/impl/HashTableUniformityTest.java | 53 ++- .../common/data/impl/InsertionOrderTest.java | 8 +- .../util/common/data/impl/LinkedNodeTest.java | 10 +- .../impl/RangeHashTablePartitionTest.java | 67 ++- ...ellableExecutionCompletableFutureTest.java | 24 +- .../search/util/common/impl/CloserTest.java | 38 +- .../common/impl/SuppressingCloserTest.java | 32 +- .../common/impl/ToStringTreeBuilderTest.java | 10 +- .../util/common/jar/impl/CodeSourceTest.java | 35 +- .../util/common/jar/impl/JandexUtilsTest.java | 27 +- .../pattern/spi/SimpleGlobPatternTest.java | 205 ++++----- .../reflect/impl/GenericTypeContextTest.java | 46 +- .../reflect/impl/ReflectionUtilsTest.java | 24 +- .../reflect/impl/ValueCreateHandleTest.java | 92 ++-- .../reflect/impl/ValueReadHandleTest.java | 159 ++++--- .../testsupport/GenericTypeContextAssert.java | 2 +- .../ElasticsearchBackendConfiguration.java | 2 +- .../dialect/ElasticsearchTestDialect.java | 4 +- .../TestElasticsearchClient.java | 46 +- .../ElasticsearchTestDialectVersionTest.java | 14 +- .../lucene/LuceneBackendConfiguration.java | 2 +- .../common/TestConfigurationProvider.java | 42 +- .../assertion/MappingAssertionHelper.java | 4 +- .../assertion/StubDocumentWorkAssert.java | 2 +- .../assertion/StubIndexScaleWorkAssert.java | 2 +- .../StubSchemaManagementWorkAssert.java | 2 +- .../assertion/StubSearchWorkAssert.java | 2 +- .../common/assertion/StubTreeNodeAssert.java | 2 +- .../ActualBackendSetupStrategy.java | 24 +- .../BackendConfiguration.java | 6 +- .../BackendIndexingWorkExpectations.java | 2 +- .../{rule => extension}/BackendMock.java | 133 ++++-- .../BackendMockSetupStrategy.java | 2 +- .../BackendSetupStrategy.java | 6 +- .../common/{rule => extension}/Call.java | 2 +- .../{rule => extension}/CallBehavior.java | 2 +- .../common/{rule => extension}/CallQueue.java | 4 +- .../CloseScrollWorkCall.java | 2 +- .../common/extension/ComposedExtension.java | 240 ++++++++++ .../{rule => extension}/CountWorkCall.java | 2 +- .../{rule => extension}/DocumentKey.java | 2 +- .../DocumentWorkCreateCall.java | 2 +- .../DocumentWorkDiscardCall.java | 2 +- .../DocumentWorkExecuteCall.java | 2 +- .../IndexScaleWorkCall.java | 2 +- .../MappingSetupHelper.java | 141 ++++-- .../NextScrollWorkCall.java | 2 +- .../ParameterizedCallBehavior.java | 2 +- .../SchemaDefinitionCall.java | 2 +- .../SchemaManagementWorkBehavior.java | 2 +- .../SchemaManagementWorkCall.java | 2 +- .../{rule => extension}/ScrollWorkCall.java | 2 +- .../{rule => extension}/SearchWorkCall.java | 2 +- .../StubNextScrollWorkBehavior.java | 2 +- .../StubSearchWorkBehavior.java | 2 +- .../common/{rule => extension}/ThreadSpy.java | 37 +- .../VerifyingStubBackendBehavior.java | 4 +- .../backend/index/impl/StubIndexManager.java | 2 +- .../index/impl/StubIndexManagerBuilder.java | 2 +- ...ckBackendIndexingWorkExpectationsTest.java | 30 +- .../integrationtest/mapper/orm/pom.xml | 4 + .../mapper/orm/BackendMockTestRule.java | 42 ++ .../orm/CoordinationStrategyExpectations.java | 2 +- .../mapper/orm/ExpectedLog4jLogTestRule.java | 42 ++ .../mapper/orm/OrmAssertionHelper.java | 2 +- .../mapper/orm/OrmSetupHelper.java | 72 ++- .../mapper/orm/ReusableOrmSetupHolder.java | 131 +++++- .../mapper/orm/SlowerLoadingListener.java | 2 +- .../mapper/orm/TestPluggableMethod.java | 2 +- .../impl/MultitenancyTestHelper.java | 8 +- .../StandalonePojoAssertionHelper.java | 4 +- .../StandalonePojoMappingSetupHelper.java | 10 +- .../test/util/impl/ExpectedLog4jLog.java | 4 +- .../util/impl/JunitJupiterContextHelper.java | 130 ++++++ .../concurrency/ConcurrentRunner.java | 2 +- .../textbuilder/TextProductionTest.java | 9 +- util/internal/test/common/pom.xml | 12 +- ...tionAndAssumptionViolationFallThrough.java | 2 +- .../search/util/impl/test/JsonHelper.java | 2 +- .../{rule => extension}/ExpectedLog4jLog.java | 80 ++-- .../impl/test/extension/RetryExtension.java | 142 ++++++ .../{rule => extension}/StaticCounters.java | 53 +-- .../log4j/Log4j2ConfigurationAccessor.java | 2 +- .../{rule => extension}/log4j/LogChecker.java | 2 +- .../log4j/LogExpectation.java | 2 +- .../log4j/TestAppender.java | 2 +- .../util/impl/test/jar/JarTestUtils.java | 16 +- .../search/util/impl/test/rule/Retry.java | 89 ---- ...nit4ClassRunnerWithEnclosingTestClass.java | 32 -- .../util/impl/test/runner/nested/Nested.java | 17 - .../impl/test/runner/nested/NestedRunner.java | 81 ---- .../NestedRunnerWithEnclosingTestClass.java | 24 - .../impl/test/reflect/RuntimeHelperTest.java | 12 +- 960 files changed, 17582 insertions(+), 16414 deletions(-) rename integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/{rule => extension}/SearchSetupHelper.java (68%) rename integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/{BackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java => AbstractBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java} (71%) create mode 100644 integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/ElasticsearchBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java create mode 100644 integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/LuceneBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java rename {util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm => integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport}/StaticIndexingSwitch.java (97%) rename util/internal/integrationtest/backend/elasticsearch/src/main/java/org/hibernate/search/util/impl/integrationtest/backend/elasticsearch/{rule => extension}/TestElasticsearchClient.java (96%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/ActualBackendSetupStrategy.java (82%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/BackendConfiguration.java (94%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/BackendIndexingWorkExpectations.java (97%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/BackendMock.java (89%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/BackendMockSetupStrategy.java (95%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/BackendSetupStrategy.java (91%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/Call.java (93%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/CallBehavior.java (80%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/CallQueue.java (98%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/CloseScrollWorkCall.java (93%) create mode 100644 util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/extension/ComposedExtension.java rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/CountWorkCall.java (94%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/DocumentKey.java (95%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/DocumentWorkCreateCall.java (96%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/DocumentWorkDiscardCall.java (96%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/DocumentWorkExecuteCall.java (97%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/IndexScaleWorkCall.java (96%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/MappingSetupHelper.java (63%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/NextScrollWorkCall.java (97%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/ParameterizedCallBehavior.java (81%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/SchemaDefinitionCall.java (96%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/SchemaManagementWorkBehavior.java (87%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/SchemaManagementWorkCall.java (96%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/ScrollWorkCall.java (97%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/SearchWorkCall.java (98%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/StubNextScrollWorkBehavior.java (95%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/StubSearchWorkBehavior.java (94%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/ThreadSpy.java (82%) rename util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/VerifyingStubBackendBehavior.java (99%) rename util/internal/integrationtest/common/src/test/java/org/hibernate/search/util/impl/integrationtest/common/{rule => extension}/BackendMockBackendIndexingWorkExpectationsTest.java (94%) create mode 100644 util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm/BackendMockTestRule.java create mode 100644 util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm/ExpectedLog4jLogTestRule.java create mode 100644 util/internal/integrationtest/v5migrationhelper/src/main/java/org/hibernate/search/test/util/impl/JunitJupiterContextHelper.java rename util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/{rule => extension}/ExpectedLog4jLog.java (76%) create mode 100644 util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/extension/RetryExtension.java rename util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/{rule => extension}/StaticCounters.java (63%) rename util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/{rule => extension}/log4j/Log4j2ConfigurationAccessor.java (96%) rename util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/{rule => extension}/log4j/LogChecker.java (98%) rename util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/{rule => extension}/log4j/LogExpectation.java (94%) rename util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/{rule => extension}/log4j/TestAppender.java (95%) delete mode 100644 util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/rule/Retry.java delete mode 100644 util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/runner/nested/BlockJUnit4ClassRunnerWithEnclosingTestClass.java delete mode 100644 util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/runner/nested/Nested.java delete mode 100644 util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/runner/nested/NestedRunner.java delete mode 100644 util/internal/test/common/src/main/java/org/hibernate/search/util/impl/test/runner/nested/NestedRunnerWithEnclosingTestClass.java diff --git a/Jenkinsfile b/Jenkinsfile index 9e2d85fd46d..00e3fe62e16 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -618,7 +618,7 @@ stage('Non-default environments') { withMavenWorkspace { // Tests may fail because of hourly AWS snapshots, // which prevent deleting indexes while they are being executed. - // Unfortunately, this triggers test failure in @BeforeClass/@AfterClass, + // Unfortunately, this triggers test failure in @BeforeAll/@AfterAll, // which cannot be handled by the maven-failsafe-plugin, // which normally re-runs failing tests, but only if // the failure occurs in the @Test method. @@ -660,7 +660,7 @@ stage('Non-default environments') { // Tests may fail because of hourly AWS snapshots, // which prevent deleting indexes while they are being executed. - // Unfortunately, this triggers test failure in @BeforeClass/@AfterClass, + // Unfortunately, this triggers test failure in @BeforeAll/@AfterAll, // which cannot be handled by the maven-failsafe-plugin, // which normally re-runs failing tests, but only if // the failure occurs in the @Test method. diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/cfg/ElasticsearchVersionTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/cfg/ElasticsearchVersionTest.java index 896aec191c5..c43ce0eb98c 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/cfg/ElasticsearchVersionTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/cfg/ElasticsearchVersionTest.java @@ -15,15 +15,15 @@ import org.hibernate.search.backend.elasticsearch.ElasticsearchVersion; import org.hibernate.search.util.common.SearchException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.assertj.core.api.AbstractBooleanAssert; import org.assertj.core.api.ObjectArrayAssert; -public class ElasticsearchVersionTest { +class ElasticsearchVersionTest { @Test - public void of_string() { + void of_string() { assertComponents( ElasticsearchVersion.of( "7" ) ) .containsExactly( ElasticsearchDistributionName.ELASTIC, 7, null, null, null ); assertComponents( ElasticsearchVersion.of( "7.0" ) ) @@ -66,7 +66,7 @@ public void of_string() { } @Test - public void of_string_forceLowercase() { + void of_string_forceLowercase() { assertComponents( ElasticsearchVersion.of( "7.0.0-Beta1" ) ) .containsExactly( ElasticsearchDistributionName.ELASTIC, 7, 0, 0, "beta1" ); assertComponents( ElasticsearchVersion.of( "ELASTIC:7.0.0-Beta1" ) ) @@ -78,7 +78,7 @@ public void of_string_forceLowercase() { } @Test - public void of_string_invalid() { + void of_string_invalid() { assertThatThrownBy( () -> ElasticsearchVersion.of( "7_0" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid Elasticsearch version", @@ -118,7 +118,7 @@ public void of_string_invalid() { } @Test - public void of_distributionNameAndString() { + void of_distributionNameAndString() { assertComponents( ElasticsearchVersion.of( ElasticsearchDistributionName.ELASTIC, "7" ) ) .containsExactly( ElasticsearchDistributionName.ELASTIC, 7, null, null, null ); assertComponents( ElasticsearchVersion.of( ElasticsearchDistributionName.ELASTIC, "7.0" ) ) @@ -158,7 +158,7 @@ public void of_distributionNameAndString() { } @Test - public void of_distributionNameAndString_invalid() { + void of_distributionNameAndString_invalid() { assertThatThrownBy( () -> ElasticsearchVersion.of( ElasticsearchDistributionName.ELASTIC, "7_0" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid Elasticsearch version", @@ -177,7 +177,7 @@ public void of_distributionNameAndString_invalid() { } @Test - public void exactMatch_elasticsearch() { + void exactMatch_elasticsearch() { assertMatch( "5.6.0", ElasticsearchDistributionName.ELASTIC, "5.6.0" ).isTrue(); assertMatch( "5.6.1", ElasticsearchDistributionName.ELASTIC, "5.6.1" ).isTrue(); assertMatch( "6.0.0", ElasticsearchDistributionName.ELASTIC, "6.0.0" ).isTrue(); @@ -192,7 +192,7 @@ public void exactMatch_elasticsearch() { } @Test - public void exactMatch_opensearch() { + void exactMatch_opensearch() { assertMatch( "opensearch:1.0.0-beta1", ElasticsearchDistributionName.OPENSEARCH, "1.0.0-beta1" ).isTrue(); assertMatch( "opensearch:1.0.0-rc1", ElasticsearchDistributionName.OPENSEARCH, "1.0.0-rc1" ).isTrue(); assertMatch( "opensearch:1.0.0-rc2", ElasticsearchDistributionName.OPENSEARCH, "1.0.0-rc2" ).isTrue(); @@ -213,7 +213,7 @@ public void exactMatch_amazonOpensearchServerless() { } @Test - public void lenientMatch_elasticsearch() { + void lenientMatch_elasticsearch() { assertMatch( "5", ElasticsearchDistributionName.ELASTIC, "5.6.0" ).isTrue(); assertMatch( "5", ElasticsearchDistributionName.ELASTIC, "5.6.1" ).isTrue(); assertMatch( "5", ElasticsearchDistributionName.ELASTIC, "5.7.1" ).isTrue(); @@ -247,7 +247,7 @@ public void lenientMatch_elasticsearch() { } @Test - public void lenientMatch_opensearch() { + void lenientMatch_opensearch() { assertMatch( "opensearch:1", ElasticsearchDistributionName.OPENSEARCH, "1.0.0-rc1" ).isTrue(); assertMatch( "opensearch:1", ElasticsearchDistributionName.OPENSEARCH, "1.0.0" ).isTrue(); assertMatch( "opensearch:1", ElasticsearchDistributionName.OPENSEARCH, "1.0.1" ).isTrue(); @@ -270,7 +270,7 @@ public void lenientMatch_opensearch() { } @Test - public void nonMatching_elastic() { + void nonMatching_elastic() { assertMatch( "5.6.0", ElasticsearchDistributionName.ELASTIC, "5.5.0" ).isFalse(); assertMatch( "5.6.0", ElasticsearchDistributionName.ELASTIC, "5.7.0" ).isFalse(); assertMatch( "5.6.0", ElasticsearchDistributionName.ELASTIC, "6.0.0" ).isFalse(); @@ -309,7 +309,7 @@ public void nonMatching_elastic() { } @Test - public void nonMatching_opensearch() { + void nonMatching_opensearch() { assertMatch( "opensearch:1.0.0", ElasticsearchDistributionName.OPENSEARCH, "1.1.0" ).isFalse(); assertMatch( "opensearch:1.0", ElasticsearchDistributionName.OPENSEARCH, "1.1.0" ).isFalse(); assertMatch( "opensearch:1.1.0", ElasticsearchDistributionName.OPENSEARCH, "1.0.0" ).isFalse(); @@ -320,7 +320,7 @@ public void nonMatching_opensearch() { } @Test - public void nonMatching_elasticAndOpensearch() { + void nonMatching_elasticAndOpensearch() { assertMatch( "7.0.0", ElasticsearchDistributionName.OPENSEARCH, "7.0.0" ).isFalse(); assertMatch( "7.0", ElasticsearchDistributionName.OPENSEARCH, "7.0.0" ).isFalse(); assertMatch( "7", ElasticsearchDistributionName.OPENSEARCH, "7.0.0" ).isFalse(); diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/client/impl/ElasticsearchClientUtilsTryGetElasticsearchVersionTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/client/impl/ElasticsearchClientUtilsTryGetElasticsearchVersionTest.java index c3599a3e0a6..dbacd54968a 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/client/impl/ElasticsearchClientUtilsTryGetElasticsearchVersionTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/client/impl/ElasticsearchClientUtilsTryGetElasticsearchVersionTest.java @@ -11,6 +11,8 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; +import java.util.Arrays; +import java.util.List; import java.util.Locale; import java.util.concurrent.CompletableFuture; @@ -20,69 +22,49 @@ import org.hibernate.search.backend.elasticsearch.client.spi.ElasticsearchResponse; import org.hibernate.search.util.common.SearchException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.google.gson.JsonObject; import org.apache.http.HttpHost; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -@RunWith(Parameterized.class) -public class ElasticsearchClientUtilsTryGetElasticsearchVersionTest { - - @Parameterized.Parameters(name = "{0} - {1}") - public static Object[][] data() { - return new Object[][] { - { null, "1.0.0", ElasticsearchDistributionName.ELASTIC, 1, 0, 0, null }, - { null, "2.0.0", ElasticsearchDistributionName.ELASTIC, 2, 0, 0, null }, - { null, "2.4.4", ElasticsearchDistributionName.ELASTIC, 2, 4, 4, null }, - { null, "5.0.0", ElasticsearchDistributionName.ELASTIC, 5, 0, 0, null }, - { null, "5.6.6", ElasticsearchDistributionName.ELASTIC, 5, 6, 6, null }, - { null, "6.0.0", ElasticsearchDistributionName.ELASTIC, 6, 0, 0, null }, - { null, "6.7.0", ElasticsearchDistributionName.ELASTIC, 6, 7, 0, null }, - { null, "7.0.0-beta1", ElasticsearchDistributionName.ELASTIC, 7, 0, 0, "beta1" }, - { null, "7.0.0", ElasticsearchDistributionName.ELASTIC, 7, 0, 0, null }, - { "opensearch", "1.0.0-rc1", ElasticsearchDistributionName.OPENSEARCH, 1, 0, 0, "rc1" }, - { "opensearch", "1.0.0", ElasticsearchDistributionName.OPENSEARCH, 1, 0, 0, null }, - { "opensearch", "1.0.1", ElasticsearchDistributionName.OPENSEARCH, 1, 0, 1, null } - }; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class ElasticsearchClientUtilsTryGetElasticsearchVersionTest { + + public static List params() { + return Arrays.asList( + Arguments.of( null, "1.0.0", ElasticsearchDistributionName.ELASTIC, 1, 0, 0, null ), + Arguments.of( null, "2.0.0", ElasticsearchDistributionName.ELASTIC, 2, 0, 0, null ), + Arguments.of( null, "2.4.4", ElasticsearchDistributionName.ELASTIC, 2, 4, 4, null ), + Arguments.of( null, "5.0.0", ElasticsearchDistributionName.ELASTIC, 5, 0, 0, null ), + Arguments.of( null, "5.6.6", ElasticsearchDistributionName.ELASTIC, 5, 6, 6, null ), + Arguments.of( null, "6.0.0", ElasticsearchDistributionName.ELASTIC, 6, 0, 0, null ), + Arguments.of( null, "6.7.0", ElasticsearchDistributionName.ELASTIC, 6, 7, 0, null ), + Arguments.of( null, "7.0.0-beta1", ElasticsearchDistributionName.ELASTIC, 7, 0, 0, "beta1" ), + Arguments.of( null, "7.0.0", ElasticsearchDistributionName.ELASTIC, 7, 0, 0, null ), + Arguments.of( "opensearch", "1.0.0-rc1", ElasticsearchDistributionName.OPENSEARCH, 1, 0, 0, "rc1" ), + Arguments.of( "opensearch", "1.0.0", ElasticsearchDistributionName.OPENSEARCH, 1, 0, 0, null ), + Arguments.of( "opensearch", "1.0.1", ElasticsearchDistributionName.OPENSEARCH, 1, 0, 1, null ) + ); } - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - - private final String distributionString; - private final String versionString; - - private final ElasticsearchDistributionName expectedDistribution; - private final int expectedMajor; - private final int expectedMinor; - private final int expectedMicro; - private final String expectedQualifier; - @Mock private ElasticsearchClient clientMock; - public ElasticsearchClientUtilsTryGetElasticsearchVersionTest(String distributionString, String versionString, + + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void testValid(String distributionString, String versionString, ElasticsearchDistributionName expectedDistribution, int expectedMajor, int expectedMinor, int expectedMicro, String expectedQualifier) { - this.distributionString = distributionString; - this.versionString = versionString; - this.expectedDistribution = expectedDistribution; - this.expectedMajor = expectedMajor; - this.expectedMinor = expectedMinor; - this.expectedMicro = expectedMicro; - this.expectedQualifier = expectedQualifier; - } - - @Test - public void testValid() { doMock( distributionString, versionString ); ElasticsearchVersion version = ElasticsearchClientUtils.tryGetElasticsearchVersion( clientMock ); assertThat( version ).isNotNull(); @@ -98,8 +80,11 @@ public void testValid() { } } - @Test - public void testInvalid_distribution() { + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void testInvalid_distribution(String distributionString, String versionString, + ElasticsearchDistributionName expectedDistribution, + int expectedMajor, int expectedMinor, int expectedMicro, String expectedQualifier) { String invalidDistributionName = "QWDWQD" + distributionString; doMock( invalidDistributionName, versionString ); assertThatThrownBy( () -> ElasticsearchClientUtils.tryGetElasticsearchVersion( clientMock ) ) @@ -107,11 +92,15 @@ public void testInvalid_distribution() { .hasMessageContainingAll( "Invalid Elasticsearch distribution name", "'" + invalidDistributionName.toLowerCase( Locale.ROOT ) + "'", - "Valid names are: [elastic, opensearch]" ); + "Valid names are: [elastic, opensearch]" + ); } - @Test - public void testInvalid_version() { + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void testInvalid_version(String distributionString, String versionString, + ElasticsearchDistributionName expectedDistribution, + int expectedMajor, int expectedMinor, int expectedMicro, String expectedQualifier) { String invalidVersionString = versionString.substring( 0, versionString.length() - 1 ) + "-A-B"; doMock( distributionString, invalidVersionString ); assertThatThrownBy( () -> ElasticsearchClientUtils.tryGetElasticsearchVersion( clientMock ) ) @@ -119,11 +108,15 @@ public void testInvalid_version() { .hasMessageContainingAll( "Invalid Elasticsearch version", "'" + invalidVersionString.toLowerCase( Locale.ROOT ) + "'", - "Expected format is 'x.y.z-qualifier'" ); + "Expected format is 'x.y.z-qualifier'" + ); } - @Test - public void testHttpStatus404() { + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + public void testHttpStatus404(String distributionString, String versionString, + ElasticsearchDistributionName expectedDistribution, + int expectedMajor, int expectedMinor, int expectedMicro, String expectedQualifier) { // This should only happen on Amazon OpenSearch Service, // which doesn't allow retrieving the version. when( clientMock.submit( any() ) ) diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/client/impl/GsonHttpEntityTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/client/impl/GsonHttpEntityTest.java index 872c78a06e5..d01661385e0 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/client/impl/GsonHttpEntityTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/client/impl/GsonHttpEntityTest.java @@ -7,7 +7,7 @@ package org.hibernate.search.backend.elasticsearch.client.impl; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; @@ -27,9 +27,9 @@ import org.hibernate.search.backend.elasticsearch.gson.spi.GsonProvider; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -40,12 +40,10 @@ import org.apache.http.Header; import org.apache.http.nio.ContentEncoder; -@RunWith(Parameterized.class) -public class GsonHttpEntityTest { +class GsonHttpEntityTest { - @Parameterized.Parameters(name = "{0}") - public static List params() { - List params = new ArrayList<>(); + public static List params() { + List params = new ArrayList<>(); Gson gson = GsonProvider.create( GsonBuilder::new, true ).getGson(); JsonObject bodyPart1 = JsonParser.parseString( "{ \"foo\": \"bar\" }" ).getAsJsonObject(); @@ -61,21 +59,24 @@ public static List params() { Arrays.asList( bodyPart1, bodyPart2, bodyPart3 ), Arrays.asList( bodyPart3, bodyPart2, bodyPart1 ) ) ) { - params.add( new Object[] { jsonObjects.toString(), jsonObjects } ); + params.add( Arguments.of( jsonObjects.toString(), jsonObjects ) ); } - params.add( new Object[] { + params.add( Arguments.of( "50 small objects", Stream.generate( () -> Arrays.asList( bodyPart1, bodyPart2, bodyPart3 ) ) - .flatMap( List::stream ).limit( 50 ).collect( Collectors.toList() ) } ); - params.add( new Object[] { + .flatMap( List::stream ).limit( 50 ).collect( Collectors.toList() ) + ) ); + params.add( Arguments.of( "200 small objects", Stream.generate( () -> Arrays.asList( bodyPart1, bodyPart2, bodyPart3 ) ) - .flatMap( List::stream ).limit( 200 ).collect( Collectors.toList() ) } ); - params.add( new Object[] { + .flatMap( List::stream ).limit( 200 ).collect( Collectors.toList() ) + ) ); + params.add( Arguments.of( "10,000 small objects", Stream.generate( () -> Arrays.asList( bodyPart1, bodyPart2, bodyPart3 ) ) - .flatMap( List::stream ).limit( 10_000 ).collect( Collectors.toList() ) } ); - params.add( new Object[] { + .flatMap( List::stream ).limit( 10_000 ).collect( Collectors.toList() ) + ) ); + params.add( Arguments.of( "200 large objects", Stream.generate( () -> { // Generate one large object @@ -87,8 +88,9 @@ public static List params() { return object; } ) // Reproduce the large object multiple times - .limit( 200 ).collect( Collectors.toList() ) } ); - params.add( new Object[] { + .limit( 200 ).collect( Collectors.toList() ) + ) ); + params.add( Arguments.of( "1 very large object", Stream.generate( () -> { JsonObject object = new JsonObject(); @@ -99,9 +101,10 @@ public static List params() { return object; } ) // Reproduce the large object multiple times - .limit( 1 ).collect( Collectors.toList() ) } ); + .limit( 1 ).collect( Collectors.toList() ) + ) ); - params.add( new Object[] { + params.add( Arguments.of( "Reproducer for HSEARCH-4239", // Yes these objects are weird, but then this is a weird edge-case. Arrays.asList( @@ -121,9 +124,9 @@ public static List params() { + "..........................................\",\"_entity_type\":\"indexNameType\"}", JsonObject.class ) ) - } ); + ) ); - params.add( new Object[] { + params.add( Arguments.of( "Reproducer for HSEARCH-4254", Arrays.asList( gson.fromJson( @@ -136,19 +139,16 @@ public static List params() { JsonObject.class ) ) - } ); + ) ); return params; } - private final List payload; - private final GsonHttpEntity gsonEntity; - private final String expectedPayloadString; - private final int expectedContentLength; + private GsonHttpEntity gsonEntity; + private String expectedPayloadString; + private int expectedContentLength; - @SuppressWarnings("unused") - public GsonHttpEntityTest(String ignoredLabel, List payload) throws IOException { - this.payload = payload; + public void init(List payload) throws IOException { Gson gson = GsonProvider.create( GsonBuilder::new, true ).getGson(); this.gsonEntity = new GsonHttpEntity( gson, payload ); StringBuilder builder = new StringBuilder(); @@ -160,23 +160,29 @@ public GsonHttpEntityTest(String ignoredLabel, List payload) throws this.expectedContentLength = StandardCharsets.UTF_8.encode( expectedPayloadString ).limit(); } - @Test - public void initialContentLength() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void initialContentLength(String ignoredLabel, List payload) throws IOException { + init( payload ); // The content length cannot be known from the start for large, multi-object payloads assumeTrue( payload.size() <= 1 || expectedContentLength < 1024 ); assertThat( gsonEntity.getContentLength() ).isEqualTo( expectedContentLength ); } - @Test - public void contentType() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void contentType(String ignoredLabel, List payload) throws IOException { + init( payload ); Header contentType = gsonEntity.getContentType(); assertThat( contentType.getName() ).isEqualTo( "Content-Type" ); assertThat( contentType.getValue() ).isEqualTo( "application/json; charset=UTF-8" ); } - @Test - public void produceContent_noPushBack() throws IOException { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void produceContent_noPushBack(String ignoredLabel, List payload) throws IOException { + init( payload ); int pushBackPeriod = Integer.MAX_VALUE; for ( int i = 0; i < 2; i++ ) { // Try several times: the result shouldn't change. assertThat( doProduceContent( gsonEntity, pushBackPeriod ) ) @@ -186,8 +192,10 @@ public void produceContent_noPushBack() throws IOException { } } - @Test - public void produceContent_pushBack_every5Bytes() throws IOException { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void produceContent_pushBack_every5Bytes(String ignoredLabel, List payload) throws IOException { + init( payload ); int pushBackPeriod = 5; for ( int i = 0; i < 2; i++ ) { // Try several times: the result shouldn't change. assertThat( doProduceContent( gsonEntity, pushBackPeriod ) ) @@ -197,8 +205,11 @@ public void produceContent_pushBack_every5Bytes() throws IOException { } } - @Test - public void produceContent_pushBack_every100Bytes() throws IOException { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void produceContent_pushBack_every100Bytes(String ignoredLabel, List payload) + throws IOException { + init( payload ); int pushBackPeriod = 100; for ( int i = 0; i < 2; i++ ) { // Try several times: the result shouldn't change. assertThat( doProduceContent( gsonEntity, pushBackPeriod ) ) @@ -208,8 +219,11 @@ public void produceContent_pushBack_every100Bytes() throws IOException { } } - @Test - public void produceContent_pushBack_every500Bytes() throws IOException { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void produceContent_pushBack_every500Bytes(String ignoredLabel, List payload) + throws IOException { + init( payload ); int pushBackPeriod = 500; for ( int i = 0; i < 2; i++ ) { // Try several times: the result shouldn't change. assertThat( doProduceContent( gsonEntity, pushBackPeriod ) ) @@ -219,8 +233,10 @@ public void produceContent_pushBack_every500Bytes() throws IOException { } } - @Test - public void writeTo() throws IOException { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void writeTo(String ignoredLabel, List payload) throws IOException { + init( payload ); for ( int i = 0; i < 2; i++ ) { // Try several times: the result shouldn't change. assertThat( doWriteTo( gsonEntity ) ) .isEqualTo( expectedPayloadString ); @@ -229,8 +245,10 @@ public void writeTo() throws IOException { } } - @Test - public void getContent() throws IOException { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void getContent(String ignoredLabel, List payload) throws IOException { + init( payload ); for ( int i = 0; i < 2; i++ ) { // Try several times: the result shouldn't change. assertThat( doGetContent( gsonEntity ) ) .isEqualTo( expectedPayloadString ); diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/dialect/impl/ElasticsearchDialectFactoryTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/dialect/impl/ElasticsearchDialectFactoryTest.java index e4ba1e52bc8..00a417e8068 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/dialect/impl/ElasticsearchDialectFactoryTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/dialect/impl/ElasticsearchDialectFactoryTest.java @@ -22,15 +22,14 @@ import org.hibernate.search.backend.elasticsearch.dialect.protocol.impl.Elasticsearch81ProtocolDialect; import org.hibernate.search.backend.elasticsearch.dialect.protocol.impl.ElasticsearchProtocolDialect; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ElasticsearchDialectFactoryTest { +class ElasticsearchDialectFactoryTest { private enum ExpectedOutcome { UNSUPPORTED, @@ -38,8 +37,7 @@ private enum ExpectedOutcome { SUCCESS } - @Parameterized.Parameters(name = "{0} {1}/{2} => {3}") - public static List params() { + public static List params() { return Arrays.asList( unsupported( ElasticsearchDistributionName.ELASTIC, "0.90.12" ), unsupported( ElasticsearchDistributionName.ELASTIC, "0.90.12" ), @@ -345,65 +343,58 @@ public static List params() { ); } - private static Object[] unsupported(ElasticsearchDistributionName distribution, String configuredVersionString) { - return new Object[] { - distribution, - configuredVersionString, - null, - ExpectedOutcome.UNSUPPORTED, - null, - null - }; + private static Arguments unsupported(ElasticsearchDistributionName distribution, String configuredVersionString) { + return Arguments.of( + distribution, configuredVersionString, null, ExpectedOutcome.UNSUPPORTED, null, null + ); } - private static Object[] successWithWarning(ElasticsearchDistributionName distribution, + private static Arguments successWithWarning(ElasticsearchDistributionName distribution, String configuredVersionString, String actualVersionString, Class expectedModelDialectClass, Class expectedProtocolDialectClass) { - return new Object[] { - distribution, - configuredVersionString, - actualVersionString, - ExpectedOutcome.SUCCESS_WITH_WARNING, - expectedModelDialectClass, - expectedProtocolDialectClass - }; + return Arguments.of( + distribution, configuredVersionString, actualVersionString, + ExpectedOutcome.SUCCESS_WITH_WARNING, expectedModelDialectClass, expectedProtocolDialectClass + ); } - private static Object[] success(ElasticsearchDistributionName distribution, + private static Arguments success(ElasticsearchDistributionName distribution, String configuredVersionString, String actualVersionString, Class expectedModelDialectClass, Class expectedProtocolDialectClass) { - return new Object[] { - distribution, - configuredVersionString, - actualVersionString, - ExpectedOutcome.SUCCESS, - expectedModelDialectClass, - expectedProtocolDialectClass - }; + return Arguments.of( + distribution, configuredVersionString, actualVersionString, + ExpectedOutcome.SUCCESS, expectedModelDialectClass, expectedProtocolDialectClass + ); } - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); private final ElasticsearchDialectFactory dialectFactory = new ElasticsearchDialectFactory(); - @Parameterized.Parameter public ElasticsearchDistributionName distributionName; - @Parameterized.Parameter(1) public String configuredVersionString; - @Parameterized.Parameter(2) public String actualVersionString; - @Parameterized.Parameter(3) - public ExpectedOutcome expectedOutcome; - @Parameterized.Parameter(4) public Class expectedModelDialectClass; - @Parameterized.Parameter(5) public Class expectedProtocolDialectClass; - @Test - public void test() { + @ParameterizedTest(name = "{0} {1}/{2} => {3}") + @MethodSource("params") + void test(ElasticsearchDistributionName distributionName, + String configuredVersionString, + String actualVersionString, + ExpectedOutcome expectedOutcome, + Class expectedModelDialectClass, + Class expectedProtocolDialectClass + ) { + this.distributionName = distributionName; + this.configuredVersionString = configuredVersionString; + this.actualVersionString = actualVersionString; + this.expectedModelDialectClass = expectedModelDialectClass; + this.expectedProtocolDialectClass = expectedProtocolDialectClass; + switch ( expectedOutcome ) { case UNSUPPORTED: testUnsupported(); diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/dialect/spi/ElasticsearchDialectsTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/dialect/spi/ElasticsearchDialectsTest.java index 1f52e939853..4a396464c70 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/dialect/spi/ElasticsearchDialectsTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/dialect/spi/ElasticsearchDialectsTest.java @@ -13,15 +13,13 @@ import org.hibernate.search.backend.elasticsearch.ElasticsearchVersion; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public class ElasticsearchDialectsTest { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return Arrays.asList( // Unsupported versions may still be precise enough params( "0.90.12", true, true, false ), @@ -47,39 +45,36 @@ public static List params() { ); } - private static Object[] params(String versionString, + private static Arguments params(String versionString, boolean isPreciseEnoughForBootstrap, boolean isPreciseEnoughForStart, boolean isVersionCheckImpossible) { - return new Object[] { + return Arguments.of( ElasticsearchVersion.of( versionString ), isPreciseEnoughForBootstrap, isPreciseEnoughForStart, isVersionCheckImpossible - }; + ); } - @Parameterized.Parameter - public ElasticsearchVersion version; - @Parameterized.Parameter(1) - public boolean isPreciseEnoughForBootstrap; - @Parameterized.Parameter(2) - public boolean isPreciseEnoughForStart; - @Parameterized.Parameter(3) - public boolean isVersionCheckImpossible; - - @Test - public void isPreciseEnoughForBootstrap() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + public void isPreciseEnoughForBootstrap(ElasticsearchVersion version, boolean isPreciseEnoughForBootstrap, + boolean isPreciseEnoughForStart, boolean isVersionCheckImpossible) { assertThat( ElasticsearchDialects.isPreciseEnoughForBootstrap( version ) ) .isEqualTo( isPreciseEnoughForBootstrap ); } - @Test - public void isPreciseEnoughForStart() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + public void isPreciseEnoughForStart(ElasticsearchVersion version, boolean isPreciseEnoughForBootstrap, + boolean isPreciseEnoughForStart, boolean isVersionCheckImpossible) { assertThat( ElasticsearchDialects.isPreciseEnoughForStart( version ) ) .isEqualTo( isPreciseEnoughForStart ); } - @Test - public void isVersionCheckImpossible() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + public void isVersionCheckImpossible(ElasticsearchVersion version, boolean isPreciseEnoughForBootstrap, + boolean isPreciseEnoughForStart, boolean isVersionCheckImpossible) { assertThat( ElasticsearchDialects.isVersionCheckImpossible( version ) ) .isEqualTo( isVersionCheckImpossible ); } diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/gson/spi/GsonClassesTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/gson/spi/GsonClassesTest.java index 900a88fdc96..99e26b811cd 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/gson/spi/GsonClassesTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/gson/spi/GsonClassesTest.java @@ -23,8 +23,8 @@ import org.hibernate.search.util.impl.test.jar.JandexTestUtils; import org.hibernate.search.util.impl.test.logging.Log; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.ClassInfo; @@ -35,13 +35,13 @@ import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; -public class GsonClassesTest { +class GsonClassesTest { private static Index gsonIndex; private static Index backendElasticsearchIndex; - @BeforeClass - public static void index() throws IOException { + @BeforeAll + static void index() throws IOException { gsonIndex = readOrBuildIndex( codeSourceLocation( Gson.class ) .orElseThrow( () -> new AssertionFailure( "Could not find Gson JAR?" ) ) ); backendElasticsearchIndex = readOrBuildIndex( codeSourceLocation( ElasticsearchExtension.class ) @@ -49,7 +49,7 @@ public static void index() throws IOException { } @Test - public void testNoMissingGsonAnnotatedClass() { + void testNoMissingGsonAnnotatedClass() { Set gsonAnnotations = findRuntimeAnnotations( gsonIndex ); Set annotatedClasses = new HashSet<>(); @@ -69,7 +69,7 @@ public void testNoMissingGsonAnnotatedClass() { } @Test - public void testNoMissingGsonContractImplementations() { + void testNoMissingGsonContractImplementations() { List gsonContracts = Arrays.asList( DotName.createSimple( TypeAdapterFactory.class.getName() ), DotName.createSimple( TypeAdapter.class.getName() ) diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/gson/spi/GsonParsingTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/gson/spi/GsonParsingTest.java index f76fc737348..f7dba647745 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/gson/spi/GsonParsingTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/gson/spi/GsonParsingTest.java @@ -8,46 +8,44 @@ import static org.assertj.core.api.Assertions.assertThatCode; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.backend.elasticsearch.lowlevel.index.mapping.impl.RootTypeMapping; import org.hibernate.search.util.impl.test.JsonHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-4580") -public class GsonParsingTest { - - @Parameterized.Parameters - public static Object[][] params() { - return new Object[][] { - { "{\"_routing\": {\"required\": true}}", RootTypeMapping.class } // HSEARCH-4580 - }; - } +class GsonParsingTest { - private final Gson gson; + private Gson gson; - @Parameterized.Parameter(0) - public String jsonToParse; - @Parameterized.Parameter(1) - public Class targetType; + public static List params() { + return Arrays.asList( + Arguments.of( "{\"_routing\": {\"required\": true}}", RootTypeMapping.class ) // HSEARCH-4580 + ); + } public GsonParsingTest() { gson = GsonProvider.create( GsonBuilder::new, true ).getGsonNoSerializeNulls(); } - @Test - public void parsingWithoutException() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void parsingWithoutException(String jsonToParse, Class targetType) { assertThatCode( () -> gson.fromJson( jsonToParse, targetType ) ).doesNotThrowAnyException(); } - @Test - public void noInformationLoss() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void noInformationLoss(String jsonToParse, Class targetType) { Object parsed = gson.fromJson( jsonToParse, targetType ); String written = gson.toJson( parsed ); JsonHelper.assertJsonEquals( jsonToParse, written ); diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchBatchedWorkProcessorTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchBatchedWorkProcessorTest.java index 9f4b6beae20..dfb509cc482 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchBatchedWorkProcessorTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchBatchedWorkProcessorTest.java @@ -18,15 +18,17 @@ import org.hibernate.search.backend.elasticsearch.work.impl.BulkableWork; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class ElasticsearchBatchedWorkProcessorTest { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class ElasticsearchBatchedWorkProcessorTest { /** * @return A value that should not matter, because it should not be used. @@ -35,16 +37,13 @@ private static T unusedReturnValue() { return null; } - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private ElasticsearchWorkSequenceBuilder sequenceBuilderMock; @Mock private ElasticsearchWorkBulker bulkerMock; @Test - public void simple_singleWork() { + void simple_singleWork() { BulkableWork work = bulkableWorkMock( 1 ); CompletableFuture sequenceFuture = new CompletableFuture<>(); @@ -78,7 +77,7 @@ public void simple_singleWork() { } @Test - public void simple_multipleWorks() { + void simple_multipleWorks() { BulkableWork work1 = bulkableWorkMock( 1 ); BulkableWork work2 = bulkableWorkMock( 2 ); @@ -117,7 +116,7 @@ public void simple_multipleWorks() { } @Test - public void newSequenceBetweenBatches() { + void newSequenceBetweenBatches() { BulkableWork work1 = bulkableWorkMock( 1 ); BulkableWork work2 = bulkableWorkMock( 2 ); diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchDefaultWorkBulkerTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchDefaultWorkBulkerTest.java index b4d39cbf115..2f3fe7348dd 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchDefaultWorkBulkerTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchDefaultWorkBulkerTest.java @@ -23,25 +23,24 @@ import org.hibernate.search.backend.elasticsearch.work.result.impl.BulkResult; import org.hibernate.search.engine.backend.work.execution.DocumentRefreshStrategy; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings("unchecked") // Raw types are the only way to mock parameterized types -public class ElasticsearchDefaultWorkBulkerTest { +class ElasticsearchDefaultWorkBulkerTest { private static final int DEFAULT_MAX_BULK_SIZE = 10; private static final DocumentRefreshStrategy DEFAULT_REFRESH = DocumentRefreshStrategy.NONE; - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private ElasticsearchWorkSequenceBuilder sequenceBuilderMock; @Mock @@ -50,7 +49,7 @@ public class ElasticsearchDefaultWorkBulkerTest { NonBulkableWork> bulkWorkFactoryMock; @Test - public void simple() { + void simple() { BulkableWork work1 = bulkableWorkMock( 1 ); BulkableWork work2 = bulkableWorkMock( 2 ); NonBulkableWork bulkWork = workMock( 3 ); @@ -101,7 +100,7 @@ public void simple() { } @Test - public void alwaysBulk() { + void alwaysBulk() { BulkableWork work1 = bulkableWorkMock( 1 ); NonBulkableWork bulkWork = workMock( 2 ); @@ -129,7 +128,7 @@ public void alwaysBulk() { } @Test - public void newBulkOnTooManyBulkedWorks() { + void newBulkOnTooManyBulkedWorks() { List> firstBulkWorks = new ArrayList<>(); for ( int i = 0; i < DEFAULT_MAX_BULK_SIZE; ++i ) { firstBulkWorks.add( bulkableWorkMock( i ) ); @@ -193,7 +192,7 @@ public void newBulkOnTooManyBulkedWorks() { } @Test - public void newBulkOnDifferentRefresh() { + void newBulkOnDifferentRefresh() { BulkableWork work1 = bulkableWorkMock( 1 ); BulkableWork work2 = bulkableWorkMock( 2 ); BulkableWork work3 = bulkableWorkMock( 3 ); diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchDefaultWorkSequenceBuilderTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchDefaultWorkSequenceBuilderTest.java index 3bbd1043134..d61a756812c 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchDefaultWorkSequenceBuilderTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/orchestration/impl/ElasticsearchDefaultWorkSequenceBuilderTest.java @@ -22,19 +22,18 @@ import org.hibernate.search.backend.elasticsearch.work.result.impl.BulkResult; import org.hibernate.search.util.common.SearchException; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings({ "unchecked", "rawtypes" }) // Raw types are the only way to mock parameterized types -public class ElasticsearchDefaultWorkSequenceBuilderTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +class ElasticsearchDefaultWorkSequenceBuilderTest { @Mock private ElasticsearchWorkExecutionContext contextMock; @@ -42,7 +41,7 @@ public class ElasticsearchDefaultWorkSequenceBuilderTest { private final List mocks = new ArrayList<>(); @Test - public void simple() { + void simple() { NonBulkableWork work1 = work( 1 ); NonBulkableWork work2 = work( 2 ); @@ -100,7 +99,7 @@ public void simple() { } @Test - public void bulk() { + void bulk() { NonBulkableWork work1 = work( 1 ); BulkableWork work2 = bulkableWork( 2 ); BulkableWork work3 = bulkableWork( 3 ); @@ -199,7 +198,7 @@ public void bulk() { } @Test - public void newSequenceOnReset() { + void newSequenceOnReset() { NonBulkableWork work1 = work( 1 ); NonBulkableWork work2 = work( 2 ); @@ -254,7 +253,7 @@ public void newSequenceOnReset() { } @Test - public void error_work() { + void error_work() { NonBulkableWork work0 = work( 0 ); NonBulkableWork work1 = work( 1 ); NonBulkableWork work2 = work( 2 ); @@ -315,7 +314,7 @@ public void error_work() { } @Test - public void error_bulk_work() { + void error_bulk_work() { BulkableWork work1 = bulkableWork( 1 ); BulkableWork work2 = bulkableWork( 2 ); BulkableWork work3 = bulkableWork( 3 ); @@ -385,7 +384,7 @@ public void error_bulk_work() { } @Test - public void error_bulk_result() { + void error_bulk_result() { BulkableWork work1 = bulkableWork( 1 ); BulkableWork work2 = bulkableWork( 2 ); BulkableWork work3 = bulkableWork( 3 ); @@ -467,7 +466,7 @@ public void error_bulk_result() { } @Test - public void error_bulk_resultExtraction_singleFailure() { + void error_bulk_resultExtraction_singleFailure() { BulkableWork work1 = bulkableWork( 1 ); BulkableWork work2 = bulkableWork( 2 ); BulkableWork work3 = bulkableWork( 3 ); @@ -546,7 +545,7 @@ public void error_bulk_resultExtraction_singleFailure() { } @Test - public void error_bulk_resultExtraction_multipleFailures() { + void error_bulk_resultExtraction_multipleFailures() { BulkableWork work1 = bulkableWork( 1 ); BulkableWork work2 = bulkableWork( 2 ); NonBulkableWork work3 = work( 3 ); @@ -617,7 +616,7 @@ public void error_bulk_resultExtraction_multipleFailures() { } @Test - public void error_bulk_resultExtraction_future_singleFailure() { + void error_bulk_resultExtraction_future_singleFailure() { BulkableWork work1 = bulkableWork( 1 ); BulkableWork work2 = bulkableWork( 2 ); BulkableWork work3 = bulkableWork( 3 ); @@ -696,7 +695,7 @@ public void error_bulk_resultExtraction_future_singleFailure() { } @Test - public void error_bulk_resultExtraction_future_multipleFailures() { + void error_bulk_resultExtraction_future_multipleFailures() { BulkableWork work1 = bulkableWork( 1 ); BulkableWork work2 = bulkableWork( 2 ); NonBulkableWork work3 = work( 3 ); @@ -777,7 +776,7 @@ public void error_bulk_resultExtraction_future_multipleFailures() { * and in the worst case could even deadlock. */ @Test - public void intertwinedSequenceExecution() { + void intertwinedSequenceExecution() { NonBulkableWork work1 = work( 1 ); NonBulkableWork work2 = work( 2 ); NonBulkableWork work3 = work( 3 ); diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/work/execution/impl/ElasticsearchIndexIndexingPlanExecutionTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/work/execution/impl/ElasticsearchIndexIndexingPlanExecutionTest.java index 4a461b13eaa..7003c9b68cc 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/work/execution/impl/ElasticsearchIndexIndexingPlanExecutionTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/work/execution/impl/ElasticsearchIndexIndexingPlanExecutionTest.java @@ -31,24 +31,23 @@ import org.hibernate.search.engine.common.EntityReference; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings("unchecked") // Raw types are the only way to mock parameterized types -public class ElasticsearchIndexIndexingPlanExecutionTest { +class ElasticsearchIndexIndexingPlanExecutionTest { private static final String TYPE_NAME = "SomeTypeName"; - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private ElasticsearchSerialWorkOrchestrator orchestratorMock; @@ -57,14 +56,14 @@ public class ElasticsearchIndexIndexingPlanExecutionTest { private final List workMocks = new ArrayList<>(); - @Before - public void setup() { + @BeforeEach + void setup() { when( entityReferenceFactoryMock.createEntityReference( eq( TYPE_NAME ), any() ) ) .thenAnswer( invocation -> entityReference( invocation.getArgument( 1 ) ) ); } @Test - public void success() { + void success() { // Work futures: we will complete them ArgumentCaptor> work1FutureCaptor = futureCaptor(); ArgumentCaptor> work2FutureCaptor = futureCaptor(); @@ -111,7 +110,7 @@ public void success() { } @Test - public void failure_work() { + void failure_work() { RuntimeException work1Exception = new RuntimeException( "work1" ); // Work futures: we will complete them @@ -161,7 +160,7 @@ public void failure_work() { } @Test - public void failure_multipleWorks() { + void failure_multipleWorks() { RuntimeException work1Exception = new RuntimeException( "work1" ); RuntimeException work3Exception = new RuntimeException( "work3" ); @@ -221,7 +220,7 @@ public void failure_multipleWorks() { @Test @TestForIssue(jiraKey = "HSEARCH-3851") - public void failure_multipleWorksAndCreateEntityReference() { + void failure_multipleWorksAndCreateEntityReference() { RuntimeException work1Exception = new RuntimeException( "work1" ); RuntimeException work3Exception = new RuntimeException( "work3" ); diff --git a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/work/impl/BulkWorkTest.java b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/work/impl/BulkWorkTest.java index 0b83a884bb8..591f011cf5a 100644 --- a/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/work/impl/BulkWorkTest.java +++ b/backend/elasticsearch/src/test/java/org/hibernate/search/backend/elasticsearch/work/impl/BulkWorkTest.java @@ -27,9 +27,9 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -37,28 +37,27 @@ import org.apache.http.HttpHost; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings({ "unchecked", "rawtypes" }) // Raw types are the only way to mock parameterized types -public class BulkWorkTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +class BulkWorkTest { @Mock private ElasticsearchClient clientMock; @Mock(strictness = Mock.Strictness.LENIENT) private ElasticsearchWorkExecutionContext contextMock; - @Before - public void setup() { + @BeforeEach + void setup() { when( contextMock.getClient() ).thenReturn( clientMock ); } @Test - public void execute_success() { + void execute_success() { BulkableWork bulkableWork0 = bulkableWork( 0 ); BulkableWork bulkableWork1 = bulkableWork( 1 ); @@ -104,7 +103,7 @@ public void execute_success() { @Test @TestForIssue(jiraKey = "HSEARCH-3869") - public void execute_http500() { + void execute_http500() { BulkableWork bulkableWork0 = bulkableWork( 0 ); BulkableWork bulkableWork1 = bulkableWork( 1 ); diff --git a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/cfg/LuceneIndexSettingsTest.java b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/cfg/LuceneIndexSettingsTest.java index 641a05f2870..63f1cffe253 100644 --- a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/cfg/LuceneIndexSettingsTest.java +++ b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/cfg/LuceneIndexSettingsTest.java @@ -8,12 +8,12 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class LuceneIndexSettingsTest { +class LuceneIndexSettingsTest { @Test - public void shardKey() { + void shardKey() { assertThat( LuceneIndexSettings.shardKey( "shardId", "foo.bar" ) ) .isEqualTo( "hibernate.search.backend.shards.shardId.foo.bar" ); diff --git a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/index/impl/IndexAccessorTest.java b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/index/impl/IndexAccessorTest.java index 1df0797eef8..4cebc288f84 100644 --- a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/index/impl/IndexAccessorTest.java +++ b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/index/impl/IndexAccessorTest.java @@ -24,25 +24,24 @@ import org.hibernate.search.engine.reporting.spi.EventContexts; import org.hibernate.search.util.common.reporting.EventContext; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.store.Directory; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class IndexAccessorTest { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class IndexAccessorTest { private static final String INDEX_NAME = "SomeIndexName"; - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - private final EventContext indexEventContext = EventContexts.fromIndexName( INDEX_NAME ); @Mock @@ -60,19 +59,19 @@ public class IndexAccessorTest { private IndexAccessorImpl accessor; - @Before - public void start() throws IOException { + @BeforeEach + void start() throws IOException { accessor = new IndexAccessorImpl( indexEventContext, directoryHolderMock, indexWriterProviderMock, indexReaderProviderMock ); } - @After - public void close() throws IOException { + @AfterEach + void close() throws IOException { accessor.close(); } @Test - public void commit() { + void commit() { when( indexWriterProviderMock.getOrNull() ).thenReturn( indexWriterDelegatorMock ); accessor.commit(); @@ -82,7 +81,7 @@ public void commit() { } @Test - public void commit_noWriter() { + void commit_noWriter() { when( indexWriterProviderMock.getOrNull() ).thenReturn( null ); accessor.commit(); @@ -92,7 +91,7 @@ public void commit_noWriter() { } @Test - public void commit_runtimeException() { + void commit_runtimeException() { RuntimeException exception = new RuntimeException( "Some message" ); when( indexWriterProviderMock.getOrNull() ).thenReturn( indexWriterDelegatorMock ); @@ -104,7 +103,7 @@ public void commit_runtimeException() { } @Test - public void commitOrDelay() { + void commitOrDelay() { when( indexWriterProviderMock.getOrNull() ).thenReturn( indexWriterDelegatorMock ); accessor.commitOrDelay(); @@ -114,7 +113,7 @@ public void commitOrDelay() { } @Test - public void commitOrDelay_noWriter() { + void commitOrDelay_noWriter() { when( indexWriterProviderMock.getOrNull() ).thenReturn( null ); accessor.commitOrDelay(); @@ -124,7 +123,7 @@ public void commitOrDelay_noWriter() { } @Test - public void commitOrDelay_runtimeException() { + void commitOrDelay_runtimeException() { RuntimeException exception = new RuntimeException( "Some message" ); when( indexWriterProviderMock.getOrNull() ).thenReturn( indexWriterDelegatorMock ); @@ -136,7 +135,7 @@ public void commitOrDelay_runtimeException() { } @Test - public void refresh() { + void refresh() { accessor.refresh(); verify( indexReaderProviderMock ).refresh(); @@ -144,7 +143,7 @@ public void refresh() { } @Test - public void refresh_runtimeException() { + void refresh_runtimeException() { RuntimeException exception = new RuntimeException( "Some message" ); doThrow( exception ).when( indexReaderProviderMock ).refresh(); @@ -155,7 +154,7 @@ public void refresh_runtimeException() { } @Test - public void mergeSegments() throws IOException { + void mergeSegments() throws IOException { when( indexWriterProviderMock.getOrCreate() ).thenReturn( indexWriterDelegatorMock ); accessor.mergeSegments(); @@ -165,7 +164,7 @@ public void mergeSegments() throws IOException { } @Test - public void getIndexWriterDelegator() throws IOException { + void getIndexWriterDelegator() throws IOException { when( indexWriterProviderMock.getOrCreate() ).thenReturn( indexWriterDelegatorMock ); assertThat( accessor.getIndexWriterDelegator() ).isSameAs( indexWriterDelegatorMock ); @@ -173,7 +172,7 @@ public void getIndexWriterDelegator() throws IOException { } @Test - public void getIndexReader() throws IOException { + void getIndexReader() throws IOException { when( indexReaderProviderMock.getOrCreate() ).thenReturn( indexReaderMock ); assertThat( accessor.getIndexReader() ).isSameAs( indexReaderMock ); @@ -181,7 +180,7 @@ public void getIndexReader() throws IOException { } @Test - public void cleanUpAfterFailure() throws IOException { + void cleanUpAfterFailure() throws IOException { Throwable exception = new RuntimeException( "Some message" ); Object failingOperation = "Some operation description"; @@ -193,7 +192,7 @@ public void cleanUpAfterFailure() throws IOException { } @Test - public void cleanUpAfterFailure_closeFailure() { + void cleanUpAfterFailure_closeFailure() { Throwable exception = new RuntimeException( "Some message" ); Object failingOperation = "Some operation description"; RuntimeException closeException = new RuntimeException( "Some other message" ); @@ -207,7 +206,7 @@ public void cleanUpAfterFailure_closeFailure() { } @Test - public void ccomputeSizeInBytes() throws IOException { + void ccomputeSizeInBytes() throws IOException { when( directoryHolderMock.get() ).thenReturn( directoryMock ); when( directoryMock.listAll() ) .thenReturn( new String[] { "file0", "file1", "file2", "file3.cfr", "file4.dv" } ); @@ -223,7 +222,7 @@ public void ccomputeSizeInBytes() throws IOException { } @Test - public void computeSizeInBytes_concurrentDeletion() throws IOException { + void computeSizeInBytes_concurrentDeletion() throws IOException { when( directoryHolderMock.get() ).thenReturn( directoryMock ); when( directoryMock.listAll() ) .thenReturn( new String[] { "file0", "file1NoSuchFile", "file2", "file3FileNotFound.cfr", "file4.dv" } ); diff --git a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/join/impl/ChildDocIdsTest.java b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/join/impl/ChildDocIdsTest.java index fa012610272..85b7e9a5dc6 100644 --- a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/join/impl/ChildDocIdsTest.java +++ b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/join/impl/ChildDocIdsTest.java @@ -13,16 +13,16 @@ import org.hibernate.search.backend.lucene.lowlevel.query.impl.ExplicitDocIdSetIterator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.apache.lucene.search.ConjunctionUtils; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.util.BitSet; -public class ChildDocIdsTest { +class ChildDocIdsTest { @Test - public void nextChild_withoutArg() throws IOException { + void nextChild_withoutArg() throws IOException { ChildDocIds childDocs = new ChildDocIds( bitSet( 2, 7, 10, 14, 20 ), docIdSetIterator( 4, 6, 9, 17, 18 ) ); assertThat( childDocs.advanceExactParent( 2 ) ).isFalse(); @@ -53,7 +53,7 @@ public void nextChild_withoutArg() throws IOException { } @Test - public void nextChild_withArg() throws IOException { + void nextChild_withArg() throws IOException { ChildDocIds childDocs = new ChildDocIds( bitSet( 2, 20 ), docIdSetIterator( 4, 6, 9, 17, 18 ) ); assertThat( childDocs.advanceExactParent( 2 ) ).isFalse(); @@ -66,7 +66,7 @@ public void nextChild_withArg() throws IOException { } @Test - public void joinedNextChild() throws IOException { + void joinedNextChild() throws IOException { DocIdSetIterator other = docIdSetIterator( 1, 5, 6, 8, 18, 20, 26, 28, 31, 36 ); ChildDocIds childDocs = new ChildDocIds( bitSet( 2, 20, 24, 30, 35, 37 ), ConjunctionUtils.intersectIterators( diff --git a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/writer/impl/LoggerInfoStreamTest.java b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/writer/impl/LoggerInfoStreamTest.java index 76c0ca94755..7483d670235 100644 --- a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/writer/impl/LoggerInfoStreamTest.java +++ b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/lowlevel/writer/impl/LoggerInfoStreamTest.java @@ -6,16 +6,16 @@ */ package org.hibernate.search.backend.lucene.lowlevel.writer.impl; -import static org.junit.Assert.assertFalse; +import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import org.hibernate.search.backend.lucene.logging.impl.LuceneLogCategories; -import org.hibernate.search.util.impl.test.rule.log4j.Log4j2ConfigurationAccessor; +import org.hibernate.search.util.impl.test.extension.log4j.Log4j2ConfigurationAccessor; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; @@ -25,7 +25,7 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.ByteBuffersDirectory; -public class LoggerInfoStreamTest { +class LoggerInfoStreamTest { private static final String LOGGER_NAME = LuceneLogCategories.INFOSTREAM_LOGGER_CATEGORY.getName(); @@ -36,19 +36,19 @@ public LoggerInfoStreamTest() { programmaticConfig = new Log4j2ConfigurationAccessor( LOGGER_NAME ); } - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { testAppender = new TestAppender( "LuceneTestAppender" ); programmaticConfig.addAppender( testAppender ); } - @After - public void tearDown() throws Exception { + @AfterEach + void tearDown() throws Exception { programmaticConfig.removeAppender(); } @Test - public void testEnableInfoStream() throws Exception { + void testEnableInfoStream() throws Exception { LoggerInfoStream infoStream = new LoggerInfoStream(); ByteBuffersDirectory directory = new ByteBuffersDirectory(); @@ -65,6 +65,6 @@ public void testEnableInfoStream() throws Exception { List logEvents = testAppender.searchByLoggerAndMessage( LOGGER_NAME, "IW:" ); - assertFalse( logEvents.isEmpty() ); + assertThat( logEvents ).isNotEmpty(); } } diff --git a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/orchestration/impl/LuceneBatchedWorkProcessorTest.java b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/orchestration/impl/LuceneBatchedWorkProcessorTest.java index 52c5cfaa93e..970e3851bb0 100644 --- a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/orchestration/impl/LuceneBatchedWorkProcessorTest.java +++ b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/orchestration/impl/LuceneBatchedWorkProcessorTest.java @@ -28,23 +28,22 @@ import org.hibernate.search.engine.reporting.spi.EventContexts; import org.hibernate.search.util.common.reporting.EventContext; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class LuceneBatchedWorkProcessorTest { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class LuceneBatchedWorkProcessorTest { private static final String INDEX_NAME = "SomeIndexName"; - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - private final EventContext indexEventContext = EventContexts.fromIndexName( INDEX_NAME ); @Mock @@ -56,13 +55,13 @@ public class LuceneBatchedWorkProcessorTest { private int nextWorkId = 0; - @Before - public void setup() { + @BeforeEach + void setup() { processor = new LuceneBatchedWorkProcessor( indexEventContext, indexAccessorMock ); } @Test - public void batch() throws IOException { + void batch() throws IOException { processor.beginBatch(); verifyNoOtherIndexInteractionsAndClear(); @@ -91,7 +90,7 @@ public void batch() throws IOException { } @Test - public void error_workExecute() throws IOException { + void error_workExecute() throws IOException { processor.beginBatch(); verifyNoOtherIndexInteractionsAndClear(); @@ -120,7 +119,7 @@ public void error_workExecute() throws IOException { } @Test - public void forceCommit() { + void forceCommit() { processor.forceCommit(); verify( indexAccessorMock ).commit(); @@ -128,7 +127,7 @@ public void forceCommit() { } @Test - public void error_forceCommit() { + void error_forceCommit() { RuntimeException commitException = new RuntimeException( "Some message" ); doThrow( commitException ).when( indexAccessorMock ).commit(); assertThatThrownBy( () -> processor.forceCommit() ) @@ -144,14 +143,14 @@ public void error_forceCommit() { } @Test - public void forceRefresh() { + void forceRefresh() { processor.forceRefresh(); verify( indexAccessorMock ).refresh(); verifyNoOtherIndexInteractionsAndClear(); } @Test - public void error_forceRefresh() { + void error_forceRefresh() { RuntimeException refreshException = new RuntimeException( "Some message" ); doThrow( refreshException ).when( indexAccessorMock ).refresh(); assertThatThrownBy( () -> processor.forceRefresh() ) @@ -160,7 +159,7 @@ public void error_forceRefresh() { } @Test - public void error_batchCommit() throws IOException { + void error_batchCommit() throws IOException { RuntimeException commitException = new RuntimeException( "Some message" ); processor.beginBatch(); diff --git a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneUnifiedSearchHighlighterPassageFormatterWithEncoderTest.java b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneUnifiedSearchHighlighterPassageFormatterWithEncoderTest.java index 37e2f8ac013..0564fa89413 100644 --- a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneUnifiedSearchHighlighterPassageFormatterWithEncoderTest.java +++ b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/search/highlighter/impl/LuceneUnifiedSearchHighlighterPassageFormatterWithEncoderTest.java @@ -8,19 +8,19 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.apache.lucene.search.highlight.DefaultEncoder; import org.apache.lucene.search.uhighlight.Passage; -public class LuceneUnifiedSearchHighlighterPassageFormatterWithEncoderTest { +class LuceneUnifiedSearchHighlighterPassageFormatterWithEncoderTest { private LuceneUnifiedSearchHighlighter.PassageFormatterWithEncoder formatter = new LuceneUnifiedSearchHighlighter.PassageFormatterWithEncoder( "", "", new DefaultEncoder() ); @Test - public void simple() { + void simple() { String text = "The quick brown fox jumps right over the little lazy dog"; Passage[] passages = new Passage[1]; @@ -39,7 +39,7 @@ public void simple() { } @Test - public void multiplePassages() { + void multiplePassages() { String text = "The quick brown fox jumps right over the little lazy dog. The five boxing wizards jump quickly"; Passage[] passages = new Passage[2]; @@ -70,7 +70,7 @@ public void multiplePassages() { } @Test - public void overlappingPassagesInFormatterFullyIncluded() { + void overlappingPassagesInFormatterFullyIncluded() { String text = "The quick brown fox jumps right over the little lazy dog"; Passage[] passages = new Passage[1]; @@ -98,7 +98,7 @@ public void overlappingPassagesInFormatterFullyIncluded() { } @Test - public void overlappingPassagesInFormatterPartialOverlapping() { + void overlappingPassagesInFormatterPartialOverlapping() { String text = "The quick brown fox jumps right over the little lazy dog"; Passage[] passages = new Passage[1]; diff --git a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/work/execution/impl/LuceneIndexIndexingPlanExecutionTest.java b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/work/execution/impl/LuceneIndexIndexingPlanExecutionTest.java index 987a0624c8e..247df4fab7a 100644 --- a/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/work/execution/impl/LuceneIndexIndexingPlanExecutionTest.java +++ b/backend/lucene/src/test/java/org/hibernate/search/backend/lucene/work/execution/impl/LuceneIndexIndexingPlanExecutionTest.java @@ -9,7 +9,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; import static org.hibernate.search.util.impl.test.FutureAssert.assertThatFuture; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doThrow; @@ -35,41 +35,35 @@ import org.hibernate.search.engine.common.EntityReference; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -@RunWith(Parameterized.class) +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings("unchecked") // Raw types are the only way to mock parameterized types -public class LuceneIndexIndexingPlanExecutionTest { +class LuceneIndexIndexingPlanExecutionTest { private static final String TYPE_NAME = "SomeTypeName"; - @Parameterized.Parameters(name = "commit = {0}, refresh = {1}") - public static Object[][] params() { - List params = new ArrayList<>(); + public static List params() { + List params = new ArrayList<>(); for ( DocumentCommitStrategy commitStrategy : DocumentCommitStrategy.values() ) { for ( DocumentRefreshStrategy refreshStrategy : DocumentRefreshStrategy.values() ) { - params.add( new Object[] { commitStrategy, refreshStrategy } ); + params.add( Arguments.of( commitStrategy, refreshStrategy ) ); } } - return params.toArray( new Object[0][] ); + return params; } - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - - private final DocumentCommitStrategy commitStrategy; - private final DocumentRefreshStrategy refreshStrategy; - @Mock private LuceneSerialWorkOrchestrator orchestratorMock; @@ -78,20 +72,15 @@ public static Object[][] params() { private final List workMocks = new ArrayList<>(); - public LuceneIndexIndexingPlanExecutionTest(DocumentCommitStrategy commitStrategy, - DocumentRefreshStrategy refreshStrategy) { - this.commitStrategy = commitStrategy; - this.refreshStrategy = refreshStrategy; - } - - @Before - public void setup() { + @BeforeEach + void setup() { when( entityReferenceFactoryMock.createEntityReference( eq( TYPE_NAME ), any() ) ) .thenAnswer( invocation -> entityReference( invocation.getArgument( 1 ) ) ); } - @Test - public void success() { + @ParameterizedTest(name = "commit = {0}, refresh = {1}") + @MethodSource("params") + void success(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { Long work1Result = 42L; Long work2Result = 41L; Long work3Result = 43L; @@ -148,8 +137,9 @@ public void success() { } ); } - @Test - public void failure_work() { + @ParameterizedTest(name = "commit = {0}, refresh = {1}") + @MethodSource("params") + void failure_work(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { RuntimeException work1Exception = new RuntimeException( "work1" ); Long work2Result = 41L; Long work3Result = 43L; @@ -207,8 +197,9 @@ public void failure_work() { } ); } - @Test - public void failure_multipleWorks() { + @ParameterizedTest(name = "commit = {0}, refresh = {1}") + @MethodSource("params") + void failure_multipleWorks(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { RuntimeException work1Exception = new RuntimeException( "work1" ); Long work2Result = 41L; RuntimeException work3Exception = new RuntimeException( "work3" ); @@ -275,9 +266,11 @@ public void failure_multipleWorks() { } ); } - @Test + @ParameterizedTest(name = "commit = {0}, refresh = {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3851") - public void failure_multipleWorksAndCreateEntityReference() { + void failure_multipleWorksAndCreateEntityReference(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy) { RuntimeException work1Exception = new RuntimeException( "work1" ); Long work2Result = 41L; RuntimeException work3Exception = new RuntimeException( "work3" ); @@ -351,11 +344,12 @@ public void failure_multipleWorksAndCreateEntityReference() { } ); } - @Test - public void failure_commit() { + @ParameterizedTest(name = "commit = {0}, refresh = {1}") + @MethodSource("params") + void failure_commit(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { assumeTrue( - "This test only makes sense when commit is forced", - DocumentCommitStrategy.FORCE.equals( commitStrategy ) + DocumentCommitStrategy.FORCE.equals( commitStrategy ), + "This test only makes sense when commit is forced" ); Long work1Result = 42L; @@ -412,11 +406,12 @@ public void failure_commit() { } ); } - @Test - public void failure_refresh() { + @ParameterizedTest(name = "commit = {0}, refresh = {1}") + @MethodSource("params") + void failure_refresh(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { assumeTrue( - "This test only makes sense when refresh is forced", - DocumentRefreshStrategy.FORCE.equals( refreshStrategy ) + DocumentRefreshStrategy.FORCE.equals( refreshStrategy ), + "This test only makes sense when refresh is forced" ); Long work1Result = 42L; @@ -475,11 +470,12 @@ public void failure_refresh() { } ); } - @Test - public void failure_workAndCommit() { + @ParameterizedTest(name = "commit = {0}, refresh = {1}") + @MethodSource("params") + void failure_workAndCommit(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { assumeTrue( - "This test only makes sense when commit is forced", - DocumentCommitStrategy.FORCE.equals( commitStrategy ) + DocumentCommitStrategy.FORCE.equals( commitStrategy ), + "This test only makes sense when commit is forced" ); RuntimeException work1Exception = new RuntimeException( "work1" ); @@ -537,11 +533,12 @@ public void failure_workAndCommit() { } ); } - @Test - public void failure_workAndRefresh() { + @ParameterizedTest(name = "commit = {0}, refresh = {1}") + @MethodSource("params") + void failure_workAndRefresh(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { assumeTrue( - "This test only makes sense when refresh is forced", - DocumentRefreshStrategy.FORCE.equals( refreshStrategy ) + DocumentRefreshStrategy.FORCE.equals( refreshStrategy ), + "This test only makes sense when refresh is forced" ); RuntimeException work1Exception = new RuntimeException( "work1" ); diff --git a/build/config/pom.xml b/build/config/pom.xml index 2f4cc08afa6..464685458e8 100644 --- a/build/config/pom.xml +++ b/build/config/pom.xml @@ -52,8 +52,12 @@ - junit - junit + org.junit.jupiter + junit-jupiter + + + org.assertj + assertj-core diff --git a/build/config/src/main/resources/forbidden-internal.txt b/build/config/src/main/resources/forbidden-internal.txt index 79456278948..52d22f247db 100644 --- a/build/config/src/main/resources/forbidden-internal.txt +++ b/build/config/src/main/resources/forbidden-internal.txt @@ -35,6 +35,8 @@ org.jboss.logging.processor.util.Objects org.assertj.core.api.Assumptions @ Use JUnit's Assume instead of AssertJ's Assumptions, because the latter use dark reflection magic and do not work with JDK11 as of 2018-12-14 org.skyscreamer.jsonassert.JSONAssert @ Use JsonHelper.assertJsonEquals to avoid the checked exception and get clearer assertion errors org.junit.experimental.runners.Enclosed @ Use NestedRunner instead of Enclosed and annotate inner classes with @Nested +org.junit.Assert @ Use AssertJ assertions instead +org.junit.jupiter.api.Assertions @ Use AssertJ assertions instead ################################################################################################################ # Unsafe API/SPI from Hibernate ORM diff --git a/build/config/src/test/java/org/hibernate/checkstyle/checks/regexp/StringSuppressorTest.java b/build/config/src/test/java/org/hibernate/checkstyle/checks/regexp/StringSuppressorTest.java index fa60ae1e46a..e6dbbc1f481 100644 --- a/build/config/src/test/java/org/hibernate/checkstyle/checks/regexp/StringSuppressorTest.java +++ b/build/config/src/test/java/org/hibernate/checkstyle/checks/regexp/StringSuppressorTest.java @@ -6,13 +6,12 @@ */ package org.hibernate.checkstyle.checks.regexp; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.puppycrawl.tools.checkstyle.api.FileContents; import com.puppycrawl.tools.checkstyle.api.FileText; @@ -20,41 +19,41 @@ /** * @author Davide D'Alto */ -public class StringSuppressorTest { +class StringSuppressorTest { @Test - public void testOutsideString() throws Exception { + void testOutsideString() throws Exception { StringSuppressor suppressor = new StringSuppressor(); suppressor.setCurrentContents( content( " " ) ); - assertFalse( suppressor.shouldSuppress( 1, 0, 0, 1 ) ); + assertThat( suppressor.shouldSuppress( 1, 0, 0, 1 ) ).isFalse(); } @Test - public void testInsideString() throws Exception { + void testInsideString() throws Exception { StringSuppressor suppressor = new StringSuppressor(); suppressor.setCurrentContents( content( "\" \"" ) ); - assertTrue( suppressor.shouldSuppress( 1, 4, 0, 6 ) ); + assertThat( suppressor.shouldSuppress( 1, 4, 0, 6 ) ).isTrue(); } @Test - public void testInsideStringWithText() throws Exception { + void testInsideStringWithText() throws Exception { StringSuppressor suppressor = new StringSuppressor(); suppressor.setCurrentContents( content( "\"text text\"" ) ); - assertTrue( suppressor.shouldSuppress( 1, 4, 0, 11 ) ); + assertThat( suppressor.shouldSuppress( 1, 4, 0, 11 ) ).isTrue(); } @Test - public void testInsideStringWithCode() throws Exception { + void testInsideStringWithCode() throws Exception { StringSuppressor suppressor = new StringSuppressor(); suppressor.setCurrentContents( content( "System.out.println(\"text text\");" ) ); - assertTrue( suppressor.shouldSuppress( 1, 25, 0, 27 ) ); + assertThat( suppressor.shouldSuppress( 1, 25, 0, 27 ) ).isTrue(); } @Test - public void testOutsideStringWithCode() throws Exception { + void testOutsideStringWithCode() throws Exception { StringSuppressor suppressor = new StringSuppressor(); suppressor.setCurrentContents( content( "System.out.println (\"text text\");" ) ); - assertFalse( suppressor.shouldSuppress( 1, 18, 0, 20 ) ); + assertThat( suppressor.shouldSuppress( 1, 18, 0, 20 ) ).isFalse(); } private FileContents content(String string) { diff --git a/build/jqassistant/rules/rules.xml b/build/jqassistant/rules/rules.xml index 798490ae8ee..dc9f746a7db 100644 --- a/build/jqassistant/rules/rules.xml +++ b/build/jqassistant/rules/rules.xml @@ -696,7 +696,7 @@ -[:ANNOTATED_BY]->()-[:OF_TYPE]->(testAnnotation:Type) WHERE NOT artifact:IntegrationTest - AND testAnnotation.fqn = "org.junit.Test" + AND (testAnnotation.fqn = "org.junit.Test" OR testAnnotation.fqn = "org.junit.jupiter.api.Test" OR testAnnotation.fqn = "org.junit.jupiter.params.ParameterizedTest") AND NOT type.name ENDS WITH "Test" AND NOT type:SuppressJQAssistant RETURN DISTINCT @@ -748,8 +748,7 @@ Nested test types should be annotated with @Nested in order to be actually executed - when their surrounding type (hopefully annotated with @RunWith(NestedInner.class)) - is executed. + when their surrounding type is executed. Exceptions are only allowed for: - Abstract test classes. @@ -765,7 +764,7 @@ // The Nested annotation OPTIONAL MATCH (nestedTestType:Type)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(nestedAnnotation:Type) WHERE - nestedAnnotation.fqn = "org.hibernate.search.util.impl.test.runner.nested.Nested" + nestedAnnotation.fqn = "org.junit.jupiter.api.Nested" WITH nestedTestType, nestedAnnotation WHERE nestedAnnotation IS NULL diff --git a/build/parents/build/pom.xml b/build/parents/build/pom.xml index 941ea85551c..c33373fc1e0 100644 --- a/build/parents/build/pom.xml +++ b/build/parents/build/pom.xml @@ -116,6 +116,8 @@ 2.20.0 4.13.2 + 5.10.0 + 1.10.0 6.0.0 2.2 @@ -668,11 +670,28 @@ + + + junit junit ${version.junit} + + + org.junit + junit-bom + ${version.junit-jupiter} + pom + import + + + + org.mockito + mockito-junit-jupiter + ${version.org.mockito} + 4 diff --git a/documentation/src/test/java/org/hibernate/search/documentation/analysis/AnalysisIT.java b/documentation/src/test/java/org/hibernate/search/documentation/analysis/AnalysisIT.java index 806d871cddf..2dec7d89d6b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/analysis/AnalysisIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/analysis/AnalysisIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.documentation.analysis; import static org.assertj.core.api.Assertions.assertThat; -import static org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration.isLucene; +import static org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration.isLucene; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; import jakarta.persistence.Entity; @@ -23,16 +23,16 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class AnalysisIT { +class AnalysisIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); @Test - public void simple() { + void simple() { EntityManagerFactory entityManagerFactory = setupHelper.start() .withProperties( isLucene() @@ -93,7 +93,7 @@ public void simple() { } @Test - public void default_override() { + void default_override() { EntityManagerFactory entityManagerFactory = setupHelper.start() .withProperties( isLucene() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/analysis/ElasticsearchAnalysisIT.java b/documentation/src/test/java/org/hibernate/search/documentation/analysis/ElasticsearchAnalysisIT.java index a2005728440..b0176719267 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/analysis/ElasticsearchAnalysisIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/analysis/ElasticsearchAnalysisIT.java @@ -23,16 +23,16 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchAnalysisIT { +class ElasticsearchAnalysisIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); @Test - public void advanced() { + void advanced() { EntityManagerFactory entityManagerFactory = setupHelper.start() .withBackendProperty( ElasticsearchIndexSettings.ANALYSIS_CONFIGURER, diff --git a/documentation/src/test/java/org/hibernate/search/documentation/analysis/LuceneAnalysisIT.java b/documentation/src/test/java/org/hibernate/search/documentation/analysis/LuceneAnalysisIT.java index b977152e969..0881cd45fc7 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/analysis/LuceneAnalysisIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/analysis/LuceneAnalysisIT.java @@ -23,16 +23,16 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class LuceneAnalysisIT { +class LuceneAnalysisIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); @Test - public void advanced() { + void advanced() { EntityManagerFactory entityManagerFactory = setupHelper.start() .withBackendProperty( LuceneBackendSettings.ANALYSIS_CONFIGURER, @@ -69,7 +69,7 @@ public void advanced() { } @Test - public void luceneClasses() { + void luceneClasses() { EntityManagerFactory entityManagerFactory = setupHelper.start() .withBackendProperty( LuceneBackendSettings.ANALYSIS_CONFIGURER, @@ -103,7 +103,7 @@ public void luceneClasses() { } @Test - public void similarity() { + void similarity() { EntityManagerFactory entityManagerFactory = setupHelper.start() .withBackendProperty( LuceneBackendSettings.ANALYSIS_CONFIGURER, diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/ElasticsearchGetClientIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/ElasticsearchGetClientIT.java index 3638aa55493..03ebb183341 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/ElasticsearchGetClientIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/ElasticsearchGetClientIT.java @@ -19,29 +19,29 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.mapping.SearchMapping; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; import org.elasticsearch.client.RestClient; -public class ElasticsearchGetClientIT { +class ElasticsearchGetClientIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void client() throws IOException { + void client() throws IOException { //tag::client[] SearchMapping mapping = /* ... */ // <1> //end::client[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/ElasticsearchHttpClientConfigurerIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/ElasticsearchHttpClientConfigurerIT.java index 573c364a12d..959db7b2495 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/ElasticsearchHttpClientConfigurerIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/ElasticsearchHttpClientConfigurerIT.java @@ -16,22 +16,22 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchHttpClientConfigurerIT { +class ElasticsearchHttpClientConfigurerIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); - @Rule - public StaticCounters staticCounters = new StaticCounters(); + @RegisterExtension + public StaticCounters staticCounters = StaticCounters.create(); @Test - public void smoke() { + void smoke() { assertThat( staticCounters.get( HttpClientConfigurer.INSTANCES ) ).isZero(); setupHelper.start() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/HttpClientConfigurer.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/HttpClientConfigurer.java index 591e629cc1d..bdd97f0d3d7 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/HttpClientConfigurer.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/client/HttpClientConfigurer.java @@ -8,7 +8,7 @@ import org.hibernate.search.backend.elasticsearch.client.ElasticsearchHttpClientConfigurationContext; import org.hibernate.search.backend.elasticsearch.client.ElasticsearchHttpClientConfigurer; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; import org.apache.http.HttpResponseInterceptor; import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/indexmanager/ElasticsearchIndexManagerIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/indexmanager/ElasticsearchIndexManagerIT.java index 9f71c1dff11..a8aaa054d31 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/indexmanager/ElasticsearchIndexManagerIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/indexmanager/ElasticsearchIndexManagerIT.java @@ -18,25 +18,25 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.mapping.SearchMapping; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchIndexManagerIT { +class ElasticsearchIndexManagerIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void readWriteName() { + void readWriteName() { //tag::readWriteName[] SearchMapping mapping = /* ... */ // <1> //end::readWriteName[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/layout/ElasticsearchCustomLayoutStrategyIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/layout/ElasticsearchCustomLayoutStrategyIT.java index b447b6a3e67..e9767437bb7 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/layout/ElasticsearchCustomLayoutStrategyIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/layout/ElasticsearchCustomLayoutStrategyIT.java @@ -21,23 +21,23 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.test.JsonHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.skyscreamer.jsonassert.JSONCompareMode; -public class ElasticsearchCustomLayoutStrategyIT { - @Rule +class ElasticsearchCustomLayoutStrategyIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); @Test - public void smoke() { + void smoke() { URLEncodedString primaryIndexName = encodeName( Book.NAME + "-20171106-191900-000000000" ); elasticsearchClient.index( primaryIndexName, null, null ) .ensureDoesNotExist(); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/mapping/ElasticsearchCustomIndexMappingIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/mapping/ElasticsearchCustomIndexMappingIT.java index 3f784a23e76..333d85001f6 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/mapping/ElasticsearchCustomIndexMappingIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/mapping/ElasticsearchCustomIndexMappingIT.java @@ -23,24 +23,24 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.JsonParser; -public class ElasticsearchCustomIndexMappingIT { +class ElasticsearchCustomIndexMappingIT { - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); @Test - public void smoke() throws Exception { + void smoke() throws Exception { EntityManagerFactory entityManagerFactory = setupHelper.start() .withBackendProperty( ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_MAPPING_FILE, diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/setting/ElasticsearchCustomIndexSettingsIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/setting/ElasticsearchCustomIndexSettingsIT.java index 8fc806dd97e..ba52d7010cb 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/setting/ElasticsearchCustomIndexSettingsIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/setting/ElasticsearchCustomIndexSettingsIT.java @@ -20,17 +20,17 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchCustomIndexSettingsIT { +class ElasticsearchCustomIndexSettingsIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); @Test - public void smoke() { + void smoke() { EntityManagerFactory entityManagerFactory = setupHelper.start() .withBackendProperty( ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_SETTINGS_FILE, diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/type/asnative/ElasticsearchNativeTypeIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/type/asnative/ElasticsearchNativeTypeIT.java index 6a418d916f5..504654d1077 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/type/asnative/ElasticsearchNativeTypeIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/elasticsearch/type/asnative/ElasticsearchNativeTypeIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchNativeTypeIT { - @Rule +class ElasticsearchNativeTypeIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( CompanyServer.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { CompanyServer companyServer = new CompanyServer(); companyServer.setIpAddress( "192.168.10.2" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/analyzer/LuceneGetAnalyzerIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/analyzer/LuceneGetAnalyzerIT.java index 3a48b43f67e..17884537d49 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/analyzer/LuceneGetAnalyzerIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/analyzer/LuceneGetAnalyzerIT.java @@ -21,27 +21,27 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.mapping.SearchMapping; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.analysis.Analyzer; -public class LuceneGetAnalyzerIT { +class LuceneGetAnalyzerIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void fromBackend() { + void fromBackend() { //tag::fromBackend[] SearchMapping mapping = /* ... */ // <1> //end::fromBackend[] @@ -57,7 +57,7 @@ public void fromBackend() { } @Test - public void fromIndexManager() { + void fromIndexManager() { //tag::fromIndexManager[] SearchMapping mapping = /* ... */ // <1> //end::fromIndexManager[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/indexmanager/LuceneGetIndexSizeIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/indexmanager/LuceneGetIndexSizeIT.java index 964ea4d705c..e705420129c 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/indexmanager/LuceneGetIndexSizeIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/indexmanager/LuceneGetIndexSizeIT.java @@ -18,25 +18,25 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.mapping.SearchMapping; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class LuceneGetIndexSizeIT { +class LuceneGetIndexSizeIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void computeIndexSize() { + void computeIndexSize() { //tag::computeIndexSize[] SearchMapping mapping = /* ... */ // <1> //end::computeIndexSize[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/lowlevel/LuceneLowLevelIndexReaderIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/lowlevel/LuceneLowLevelIndexReaderIT.java index f57ec9e32db..5ce88976758 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/lowlevel/LuceneLowLevelIndexReaderIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/lowlevel/LuceneLowLevelIndexReaderIT.java @@ -18,27 +18,27 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.mapping.SearchMapping; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.index.IndexReader; -public class LuceneLowLevelIndexReaderIT { +class LuceneLowLevelIndexReaderIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void indexReader() throws Exception { + void indexReader() throws Exception { int numDocs; //tag::indexReader[] SearchMapping mapping = /* ... */ // <1> diff --git a/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/type/asnative/LuceneNativeTypeIT.java b/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/type/asnative/LuceneNativeTypeIT.java index af30309c1fd..be195decd42 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/type/asnative/LuceneNativeTypeIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/backend/lucene/type/asnative/LuceneNativeTypeIT.java @@ -19,25 +19,25 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.document.FeatureField; -public class LuceneNativeTypeIT { - @Rule +class LuceneNativeTypeIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( WebPage.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { WebPage webPage1 = new WebPage(); webPage1.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/configuration/ElasticsearchConfigurationIT.java b/documentation/src/test/java/org/hibernate/search/documentation/configuration/ElasticsearchConfigurationIT.java index 9d549a4228a..54fff2ab332 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/configuration/ElasticsearchConfigurationIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/configuration/ElasticsearchConfigurationIT.java @@ -19,9 +19,9 @@ import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategyNames; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ElasticsearchConfigurationIT { +class ElasticsearchConfigurationIT { // tag::build-hibernate-configuration[] private Properties buildHibernateConfiguration() { Properties config = new Properties(); @@ -45,7 +45,7 @@ private Properties buildHibernateConfiguration() { // end::build-hibernate-configuration[] @Test - public void shouldBuildHibernateConfiguration() { + void shouldBuildHibernateConfiguration() { assertThat( buildHibernateConfiguration() ) .containsOnly( entry( "hibernate.search.backend.hosts", "127.0.0.1:9200" ), diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/alternative/alternativebinder/AlternativeBinderIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/alternative/alternativebinder/AlternativeBinderIT.java index fd6db38253e..9cfd507a4ad 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/alternative/alternativebinder/AlternativeBinderIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/alternative/alternativebinder/AlternativeBinderIT.java @@ -17,22 +17,19 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.environment.bean.BeanReference; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.bridge.builtin.programmatic.AlternativeBinder; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class AlternativeBinderIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class AlternativeBinderIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep blogEntryMapping = mapping.type( BlogEntry.class ); @@ -46,19 +43,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( BlogEntry.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { BlogEntry entry1 = new BlogEntry(); entry1.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/automaticindexing/HibernateOrmIndexingPlanFilterIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/automaticindexing/HibernateOrmIndexingPlanFilterIT.java index e01e97d658f..31e9185f2f7 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/automaticindexing/HibernateOrmIndexingPlanFilterIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/automaticindexing/HibernateOrmIndexingPlanFilterIT.java @@ -24,26 +24,26 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class HibernateOrmIndexingPlanFilterIT { +class HibernateOrmIndexingPlanFilterIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { this.entityManagerFactory = setupHelper.start() .setup( EntityA.class, EntityExtendsA1.class, EntityExtendsA2.class ); } @Test - public void applicationFilterOnly() { + void applicationFilterOnly() { // tag::application-filter[] SearchMapping searchMapping = /* ... */ // <1> // end::application-filter[] @@ -71,7 +71,7 @@ public void applicationFilterOnly() { } @Test - public void sessionFilterOnly() { + void sessionFilterOnly() { with( entityManagerFactory ).runInTransaction( entityManager -> { // tag::session-filter[] SearchSession session = /* ... */ // <1> @@ -100,7 +100,7 @@ public void sessionFilterOnly() { } @Test - public void disableAll() { + void disableAll() { with( entityManagerFactory ).runInTransaction( entityManager -> { // tag::session-filter-exclude-all[] SearchSession searchSession = /* ... */ // <1> @@ -128,7 +128,7 @@ public void disableAll() { } @Test - public void disableAllApplicationEnableSession() { + void disableAllApplicationEnableSession() { // tag::session-filter-exclude-include-all-application[] SearchMapping searchMapping = /* ... */ // <1> // end::session-filter-exclude-include-all-application[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/bridgeresolver/BridgeResolverIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/bridgeresolver/BridgeResolverIT.java index 8092533ce9b..2ccde054d7e 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/bridgeresolver/BridgeResolverIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/bridgeresolver/BridgeResolverIT.java @@ -21,19 +21,19 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class BridgeResolverIT { +class BridgeResolverIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.MAPPING_CONFIGURER, @@ -43,7 +43,7 @@ public void setup() { } @Test - public void smoke() { + void smoke() { MyProductId book1Id = new MyProductId( "oreilly", "14425" ); ISBN book1Isbn = ISBN.parse( "978-0-58-600835-5" ); MyProductId book2Id = new MyProductId( "largevue", "84784-484-44" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/fromotherentity/DependenciesFromOtherEntityIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/fromotherentity/DependenciesFromOtherEntityIT.java index 9911a381cdf..7d3ad0de156 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/fromotherentity/DependenciesFromOtherEntityIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/fromotherentity/DependenciesFromOtherEntityIT.java @@ -16,23 +16,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DependenciesFromOtherEntityIT { - @Rule +class DependenciesFromOtherEntityIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( ScientificPaper.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { ScientificPaper paper1 = new ScientificPaper( 1 ); paper1.setTitle( diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/property/DependenciesContainersPropertyIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/property/DependenciesContainersPropertyIT.java index 9c9f259de77..e3fd0e00f59 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/property/DependenciesContainersPropertyIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/property/DependenciesContainersPropertyIT.java @@ -19,24 +19,24 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DependenciesContainersPropertyIT { +class DependenciesContainersPropertyIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, BookEdition.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setTitle( "The Caves Of Steel" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/simple/DependenciesContainersSimpleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/simple/DependenciesContainersSimpleIT.java index e0fc042898b..efcce7e0194 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/simple/DependenciesContainersSimpleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/containers/simple/DependenciesContainersSimpleIT.java @@ -19,24 +19,24 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DependenciesContainersSimpleIT { +class DependenciesContainersSimpleIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, BookEdition.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setTitle( "The Caves Of Steel" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/simple/DependenciesSimpleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/simple/DependenciesSimpleIT.java index f59ace16f03..290b3e6e51a 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/simple/DependenciesSimpleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/dependencies/simple/DependenciesSimpleIT.java @@ -18,23 +18,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DependenciesSimpleIT { - @Rule +class DependenciesSimpleIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Author author = new Author(); author.setFirstName( "Isaac" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/dynamic/DocumentModelDslDynamicIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/dynamic/DocumentModelDslDynamicIT.java index 5657e195cf0..b1ca79cdaa2 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/dynamic/DocumentModelDslDynamicIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/dynamic/DocumentModelDslDynamicIT.java @@ -18,23 +18,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DocumentModelDslDynamicIT { - @Rule +class DocumentModelDslDynamicIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book1 = new Book(); book1.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/object/DocumentModelDslObjectIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/object/DocumentModelDslObjectIT.java index 232cb8040df..b8827880e64 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/object/DocumentModelDslObjectIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/object/DocumentModelDslObjectIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DocumentModelDslObjectIT { - @Rule +class DocumentModelDslObjectIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Invoice.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Invoice invoice = new Invoice(); invoice.getLineItems() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/simple/DocumentModelDslSimpleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/simple/DocumentModelDslSimpleIT.java index de77d05d0c4..d4c6a79b2fe 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/simple/DocumentModelDslSimpleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/document/model/dsl/simple/DocumentModelDslSimpleIT.java @@ -20,23 +20,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DocumentModelDslSimpleIT { - @Rule +class DocumentModelDslSimpleIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Author.class, Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( ISBN.parse( "978-0-58-600835-5" ) ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/dslconverter/IndexFieldTypeDslDslConverterIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/dslconverter/IndexFieldTypeDslDslConverterIT.java index 57eba17ddc2..589c61acac4 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/dslconverter/IndexFieldTypeDslDslConverterIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/dslconverter/IndexFieldTypeDslDslConverterIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexFieldTypeDslDslConverterIT { - @Rule +class IndexFieldTypeDslDslConverterIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( ISBN.parse( "978-0-58-600835-5" ) ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/projectionconverter/IndexFieldTypeDslProjectionConverterIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/projectionconverter/IndexFieldTypeDslProjectionConverterIT.java index a0d4c848d81..3cbe2be899b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/projectionconverter/IndexFieldTypeDslProjectionConverterIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/projectionconverter/IndexFieldTypeDslProjectionConverterIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexFieldTypeDslProjectionConverterIT { - @Rule +class IndexFieldTypeDslProjectionConverterIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( ISBN.parse( "978-0-58-600835-5" ) ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/simple/IndexFieldTypeDslSimpleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/simple/IndexFieldTypeDslSimpleIT.java index 0fcffa4c65f..c26b2489a0b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/simple/IndexFieldTypeDslSimpleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/fieldtypes/dsl/simple/IndexFieldTypeDslSimpleIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexFieldTypeDslSimpleIT { - @Rule +class IndexFieldTypeDslSimpleIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( ISBN.parse( "978-0-58-600835-5" ) ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/binder/IdentifierBinderIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/binder/IdentifierBinderIT.java index b8e79064910..2f9f6a066c9 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/binder/IdentifierBinderIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/binder/IdentifierBinderIT.java @@ -16,21 +16,18 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class IdentifierBinderIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class IdentifierBinderIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -41,19 +38,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/compatible/IdentifierBridgeCompatibleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/compatible/IdentifierBridgeCompatibleIT.java index 5ff8dfd47d5..f7ae6e0097f 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/compatible/IdentifierBridgeCompatibleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/compatible/IdentifierBridgeCompatibleIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IdentifierBridgeCompatibleIT { - @Rule +class IdentifierBridgeCompatibleIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Magazine.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.getId().setPublisherId( 1L ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/ormcontext/IdentifierBridgeOrmContextIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/ormcontext/IdentifierBridgeOrmContextIT.java index 881e7f492b5..3fbe9673606 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/ormcontext/IdentifierBridgeOrmContextIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/ormcontext/IdentifierBridgeOrmContextIT.java @@ -18,23 +18,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IdentifierBridgeOrmContextIT { - @Rule +class IdentifierBridgeOrmContextIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( MyEntity.class ); } @Test - public void smoke() { + void smoke() { // See MyDataValueBridge entityManagerFactory.getProperties().put( "test.data.indexed", MyData.VALUE1 ); with( entityManagerFactory ).runInTransaction( entityManager -> { diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/param/annotation/IdentifierBridgeParamAnnotationIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/param/annotation/IdentifierBridgeParamAnnotationIT.java index cb9ccae6e59..2d36a9b7c30 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/param/annotation/IdentifierBridgeParamAnnotationIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/param/annotation/IdentifierBridgeParamAnnotationIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IdentifierBridgeParamAnnotationIT { - @Rule +class IdentifierBridgeParamAnnotationIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book1 = new Book(); book1.setId( 0 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/param/string/IdentifierBridgeParamStringIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/param/string/IdentifierBridgeParamStringIT.java index c021ae33d58..dcec0172f73 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/param/string/IdentifierBridgeParamStringIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/param/string/IdentifierBridgeParamStringIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IdentifierBridgeParamStringIT { - @Rule +class IdentifierBridgeParamStringIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book1 = new Book(); book1.setId( 0 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/simple/IdentifierBridgeSimpleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/simple/IdentifierBridgeSimpleIT.java index f0ef06be147..2d304134ac1 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/simple/IdentifierBridgeSimpleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/identifierbridge/simple/IdentifierBridgeSimpleIT.java @@ -16,21 +16,18 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class IdentifierBridgeSimpleIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class IdentifierBridgeSimpleIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -41,19 +38,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/namedpredicate/NamedPredicateIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/namedpredicate/NamedPredicateIT.java index 5c7e6cbfbff..9518d397894 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/namedpredicate/NamedPredicateIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/namedpredicate/NamedPredicateIT.java @@ -18,23 +18,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class NamedPredicateIT { - @Rule +class NamedPredicateIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( ItemStock.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { ItemStock unit1 = new ItemStock(); unit1.setSkuId( "SHOES.WI2012.4242" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/bridgedelement/PropertyBridgeBridgedElementIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/bridgedelement/PropertyBridgeBridgedElementIT.java index 468a6000b95..53fbe1aebd2 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/bridgedelement/PropertyBridgeBridgedElementIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/bridgedelement/PropertyBridgeBridgedElementIT.java @@ -19,21 +19,18 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class PropertyBridgeBridgedElementIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class PropertyBridgeBridgedElementIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep invoiceMapping = mapping.type( Invoice.class ); @@ -43,19 +40,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Invoice.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Invoice invoice = new Invoice(); invoice.getLineItems() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/ormcontext/PropertyBridgeOrmContextIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/ormcontext/PropertyBridgeOrmContextIT.java index 9ea2f473770..c9b66827a60 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/ormcontext/PropertyBridgeOrmContextIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/ormcontext/PropertyBridgeOrmContextIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class PropertyBridgeOrmContextIT { - @Rule +class PropertyBridgeOrmContextIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( MyEntity.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { // See MyDataPropertyBinder entityManager.setProperty( "test.data.indexed", MyData.INDEXED ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/param/annotation/PropertyBridgeParamAnnotationIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/param/annotation/PropertyBridgeParamAnnotationIT.java index b0a95271270..81998852dfd 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/param/annotation/PropertyBridgeParamAnnotationIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/param/annotation/PropertyBridgeParamAnnotationIT.java @@ -17,21 +17,18 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class PropertyBridgeParamAnnotationIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class PropertyBridgeParamAnnotationIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep invoiceMapping = mapping.type( Invoice.class ); @@ -42,19 +39,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Invoice.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Invoice invoice = new Invoice(); invoice.getLineItems() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/param/string/PropertyBridgeParamStringIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/param/string/PropertyBridgeParamStringIT.java index c593f0f1b1d..f809d40d449 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/param/string/PropertyBridgeParamStringIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/param/string/PropertyBridgeParamStringIT.java @@ -20,21 +20,18 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class PropertyBridgeParamStringIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class PropertyBridgeParamStringIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep invoiceMapping = mapping.type( Invoice.class ); @@ -45,19 +42,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Invoice.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Invoice invoice = new Invoice(); invoice.getLineItems() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/simple/PropertyBridgeSimpleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/simple/PropertyBridgeSimpleIT.java index f1b3ba2313c..94fb671cc1e 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/simple/PropertyBridgeSimpleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/propertybridge/simple/PropertyBridgeSimpleIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class PropertyBridgeSimpleIT { - @Rule +class PropertyBridgeSimpleIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Invoice.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Invoice invoice = new Invoice(); invoice.getLineItems() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/conditionalindexing/RoutingBridgeConditionalIndexingIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/conditionalindexing/RoutingBridgeConditionalIndexingIT.java index 306f07eff20..d14bcf2debc 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/conditionalindexing/RoutingBridgeConditionalIndexingIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/conditionalindexing/RoutingBridgeConditionalIndexingIT.java @@ -17,27 +17,24 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.search.query.SearchResult; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class RoutingBridgeConditionalIndexingIT { +class RoutingBridgeConditionalIndexingIT { private static final int BOOK1_ID = 1; private static final int BOOK2_ID = 2; private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -48,20 +45,22 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); initData(); } - @Test - public void test() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void test(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); SearchResult result = searchSession.search( Book.class ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/ormcontext/RoutingBridgeOrmContextIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/ormcontext/RoutingBridgeOrmContextIT.java index 4537eca9b8e..b3a6f1dc34e 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/ormcontext/RoutingBridgeOrmContextIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/ormcontext/RoutingBridgeOrmContextIT.java @@ -18,27 +18,27 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class RoutingBridgeOrmContextIT { +class RoutingBridgeOrmContextIT { private static final int SHARD_COUNT = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.hashBasedSharding( SHARD_COUNT ) ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( MyEntity.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { // See MyDataPropertyBinder entityManager.setProperty( "test.data.indexed", MyData.INDEXED ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/routingkey/RoutingBridgeRoutingKeyIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/routingkey/RoutingBridgeRoutingKeyIT.java index 5f79d21020e..17a6f1da31b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/routingkey/RoutingBridgeRoutingKeyIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/routingbridge/routingkey/RoutingBridgeRoutingKeyIT.java @@ -17,17 +17,16 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.search.query.SearchResult; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class RoutingBridgeRoutingKeyIT { +class RoutingBridgeRoutingKeyIT { private static final int SHARD_COUNT = 4; @@ -36,10 +35,8 @@ public class RoutingBridgeRoutingKeyIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.hashBasedSharding( SHARD_COUNT ), mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -50,20 +47,22 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.hashBasedSharding( SHARD_COUNT ) ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); initData(); } - @Test - public void routing_single() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void routing_single(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::routing-single[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/ormcontext/TypeBridgeOrmContextIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/ormcontext/TypeBridgeOrmContextIT.java index e68a9ace8a5..f9ac37a8dd3 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/ormcontext/TypeBridgeOrmContextIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/ormcontext/TypeBridgeOrmContextIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class TypeBridgeOrmContextIT { - @Rule +class TypeBridgeOrmContextIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( MyEntity.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { // See MyDataPropertyBinder entityManager.setProperty( "test.data.indexed", MyData.INDEXED ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/param/annotation/TypeBridgeParamAnnotationIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/param/annotation/TypeBridgeParamAnnotationIT.java index 7badb9ecf5f..24f6fa20541 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/param/annotation/TypeBridgeParamAnnotationIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/param/annotation/TypeBridgeParamAnnotationIT.java @@ -16,21 +16,18 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class TypeBridgeParamAnnotationIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class TypeBridgeParamAnnotationIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep authorMapping = mapping.type( Author.class ); @@ -40,19 +37,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Author.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Author author1 = new Author(); author1.setFirstName( "Ty" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/param/string/TypeBridgeParamStringIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/param/string/TypeBridgeParamStringIT.java index 01b3f597ae1..7c4675f6897 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/param/string/TypeBridgeParamStringIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/param/string/TypeBridgeParamStringIT.java @@ -17,21 +17,18 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class TypeBridgeParamStringIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class TypeBridgeParamStringIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep authorMapping = mapping.type( Author.class ); @@ -41,19 +38,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Author.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Author author1 = new Author(); author1.setFirstName( "Ty" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/simple/TypeBridgeSimpleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/simple/TypeBridgeSimpleIT.java index a5e995af817..4f38c2e6484 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/simple/TypeBridgeSimpleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/typebridge/simple/TypeBridgeSimpleIT.java @@ -18,23 +18,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class TypeBridgeSimpleIT { - @Rule +class TypeBridgeSimpleIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Author.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Author author = new Author(); author.setFirstName( "Isaac" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/binder/ValueBridgeBinderIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/binder/ValueBridgeBinderIT.java index 0277ce87705..2558ef6ec3b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/binder/ValueBridgeBinderIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/binder/ValueBridgeBinderIT.java @@ -18,21 +18,18 @@ import org.hibernate.search.documentation.testsupport.data.ISBN; import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ValueBridgeBinderIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class ValueBridgeBinderIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { // @formatter:off //tag::programmatic[] @@ -47,19 +44,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( ISBN.parse( "978-0-58-600835-5" ) ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/compatible/ValueBridgeCompatibleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/compatible/ValueBridgeCompatibleIT.java index 2c5888fed9f..24c22cfc73a 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/compatible/ValueBridgeCompatibleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/compatible/ValueBridgeCompatibleIT.java @@ -20,23 +20,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ValueBridgeCompatibleIT { - @Rule +class ValueBridgeCompatibleIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book1.class, Book2.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book1 book1 = new Book1(); book1.setIsbn( ISBN.parse( "978-0-58-600835-5" ) ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/indexnullas/ValueBridgeIndexNullAsIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/indexnullas/ValueBridgeIndexNullAsIT.java index 2c984c17284..e54f00543b4 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/indexnullas/ValueBridgeIndexNullAsIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/indexnullas/ValueBridgeIndexNullAsIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ValueBridgeIndexNullAsIT { - @Rule +class ValueBridgeIndexNullAsIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( null ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/ormcontext/ValueBridgeOrmContextIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/ormcontext/ValueBridgeOrmContextIT.java index b8681eae758..949aba9a484 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/ormcontext/ValueBridgeOrmContextIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/ormcontext/ValueBridgeOrmContextIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ValueBridgeOrmContextIT { - @Rule +class ValueBridgeOrmContextIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( MyEntity.class ); } @Test - public void smoke() { + void smoke() { // See MyDataValueBridge entityManagerFactory.getProperties().put( "test.data.indexed", MyData.INDEXED ); with( entityManagerFactory ).runInTransaction( entityManager -> { diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/param/annotation/ValueBridgeParamAnnotationIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/param/annotation/ValueBridgeParamAnnotationIT.java index 43e8141b338..8cf935f9063 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/param/annotation/ValueBridgeParamAnnotationIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/param/annotation/ValueBridgeParamAnnotationIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ValueBridgeParamAnnotationIT { - @Rule +class ValueBridgeParamIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book1 = new Book(); book1.setTitle( "The Government Is Evil" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/param/string/ValueBridgeParamStringIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/param/string/ValueBridgeParamStringIT.java index 8b1b3363327..28250ba0a6f 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/param/string/ValueBridgeParamStringIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/param/string/ValueBridgeParamStringIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ValueBridgeParamStringIT { - @Rule +class ValueBridgeParamIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book1 = new Book(); book1.setTitle( "The Government Is Evil" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/projection/ValueBridgeProjectionIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/projection/ValueBridgeProjectionIT.java index 8a46abf3106..7978b2739f5 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/projection/ValueBridgeProjectionIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/projection/ValueBridgeProjectionIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ValueBridgeProjectionIT { - @Rule +class ValueBridgeProjectionIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( ISBN.parse( "978-0-58-600835-5" ) ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/simple/ValueBridgeSimpleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/simple/ValueBridgeSimpleIT.java index 88ecbd57334..328cedd254a 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/simple/ValueBridgeSimpleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/binding/valuebridge/simple/ValueBridgeSimpleIT.java @@ -17,21 +17,18 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.documentation.testsupport.data.ISBN; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ValueBridgeSimpleIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class ValueBridgeSimpleIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -42,19 +39,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( ISBN.parse( "978-0-58-600835-5" ) ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/containerextractor/ContainerExtractorIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/containerextractor/ContainerExtractorIT.java index 55082e56ea4..23a97a0c2f7 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/containerextractor/ContainerExtractorIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/containerextractor/ContainerExtractorIT.java @@ -18,23 +18,20 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.search.common.ValueConvert; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.extractor.builtin.BuiltinContainerExtractors; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ContainerExtractorIT { +class ContainerExtractorIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { TypeMappingStep bookMapping = mapping.type( Book.class ); bookMapping.indexed(); @@ -54,19 +51,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, Author.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Author author = new Author(); author.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/directfieldmapping/HibernateOrmSimpleMappingIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/directfieldmapping/HibernateOrmSimpleMappingIT.java index 328fdfa1d75..6f794bc5cba 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/directfieldmapping/HibernateOrmSimpleMappingIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/directfieldmapping/HibernateOrmSimpleMappingIT.java @@ -18,20 +18,19 @@ import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test that the simple mapping defined in Book works as expected. */ -@RunWith(Parameterized.class) -public class HibernateOrmSimpleMappingIT { +class HibernateOrmSimpleMappingIT { private static final String BOOK1_TITLE = "I, Robot"; private static final Integer BOOK1_PAGECOUNT = 224; @@ -41,10 +40,8 @@ public class HibernateOrmSimpleMappingIT { private static final String BOOK3_TITLE = "The Robots of Dawn"; private static final Integer BOOK3_PAGECOUNT = 435; - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { // @formatter:off //tag::programmatic[] @@ -62,20 +59,22 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); initData(); } - @Test - public void sort() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void sort(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -92,8 +91,10 @@ public void sort() { } ); } - @Test - public void projection_simple() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projection_simple(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/entityindexmapping/HibernateOrmIndexedIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/entityindexmapping/HibernateOrmIndexedIT.java index 2aafff06181..9c73dc2847b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/entityindexmapping/HibernateOrmIndexedIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/entityindexmapping/HibernateOrmIndexedIT.java @@ -20,19 +20,18 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class HibernateOrmIndexedIT { +class HibernateOrmIndexedIT { private static final String BACKEND_2 = "backend2"; @@ -46,10 +45,8 @@ public class HibernateOrmIndexedIT { NAMED_BACKEND_CONFIGURATIONS = map; } - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - DEFAULT_BACKEND_CONFIGURATION, NAMED_BACKEND_CONFIGURATIONS, mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -63,20 +60,23 @@ public static List params() { ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withMultipleBackends( + DEFAULT_BACKEND_CONFIGURATION, NAMED_BACKEND_CONFIGURATIONS ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, User.class, Author.class ); initData(); } - @Test - public void search_separateQueries() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void search_separateQueries(Boolean annotationProcessingEnabled, + HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -92,8 +92,11 @@ public void search_separateQueries() { } ); } - @Test - public void search_singleQuery() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void search_singleQuery(Boolean annotationProcessingEnabled, + HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); assertThatThrownBy( () -> with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/entrypoints/HibernateOrmEntryPointsIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/entrypoints/HibernateOrmEntryPointsIT.java index 4d7406e0a67..66d71c32bcb 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/entrypoints/HibernateOrmEntryPointsIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/entrypoints/HibernateOrmEntryPointsIT.java @@ -24,25 +24,25 @@ import org.hibernate.search.mapper.orm.scope.SearchScope; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class HibernateOrmEntryPointsIT { +class HibernateOrmEntryPointsIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private SessionFactory theSessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { this.theSessionFactory = setupHelper.start() .setup( Book.class, Associate.class, Manager.class ); } @Test - public void searchMapping_fromSessionFactory() { + void searchMapping_fromSessionFactory() { // tag::searchMapping-fromSessionFactory[] SessionFactory sessionFactory = /* ... */ // <1> // end::searchMapping-fromSessionFactory[] @@ -55,7 +55,7 @@ public void searchMapping_fromSessionFactory() { } @Test - public void searchMapping_fromEntityManagerFactory() { + void searchMapping_fromEntityManagerFactory() { // tag::searchMapping-fromEntityManagerFactory[] EntityManagerFactory entityManagerFactory = /* ... */ // <1> // end::searchMapping-fromEntityManagerFactory[] @@ -68,7 +68,7 @@ public void searchMapping_fromEntityManagerFactory() { } @Test - public void searchSession_fromSession() { + void searchSession_fromSession() { with( theSessionFactory ).runNoTransaction( theSession -> { // tag::searchSession-fromSession[] Session session = /* ... */ // <1> @@ -83,7 +83,7 @@ public void searchSession_fromSession() { } @Test - public void searchSession_fromEntityManager() { + void searchSession_fromEntityManager() { with( theSessionFactory ).runNoTransaction( theSession -> { // tag::searchSession-fromEntityManager[] EntityManager entityManager = /* ... */ // <1> @@ -98,7 +98,7 @@ public void searchSession_fromEntityManager() { } @Test - public void searchScope_fromSearchMapping() { + void searchScope_fromSearchMapping() { // tag::searchScope-fromSearchMapping[] SearchMapping searchMapping = /* ... */ // <1> // end::searchScope-fromSearchMapping[] @@ -129,7 +129,7 @@ public void searchScope_fromSearchMapping() { } @Test - public void searchScope_fromSearchSession() { + void searchScope_fromSearchSession() { with( theSessionFactory ).runNoTransaction( theSession -> { // tag::searchScope-fromSearchSession[] SearchSession searchSession = /* ... */ // <1> diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withhsearch/customanalysis/GettingStartedCustomAnalysisIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withhsearch/customanalysis/GettingStartedCustomAnalysisIT.java index 95dda5a6b99..c10eaeda656 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withhsearch/customanalysis/GettingStartedCustomAnalysisIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withhsearch/customanalysis/GettingStartedCustomAnalysisIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.documentation.mapper.orm.gettingstarted.withhsearch.customanalysis; import static org.assertj.core.api.Assertions.assertThat; -import static org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration.BACKEND_TYPE; +import static org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration.BACKEND_TYPE; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; import java.util.concurrent.atomic.AtomicReference; @@ -21,35 +21,35 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class GettingStartedCustomAnalysisIT { +class GettingStartedCustomAnalysisIT { private final String persistenceUnitName = "GettingStartedCustomAnalysisIT_" + BACKEND_TYPE; private EntityManagerFactory entityManagerFactory; - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = Persistence.createEntityManagerFactory( persistenceUnitName, TestConfiguration.ormMapperProperties( configurationProvider ) ); } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( entityManagerFactory != null ) { entityManagerFactory.close(); } } @Test - public void test() { + void test() { AtomicReference bookIdHolder = new AtomicReference<>(); with( entityManagerFactory ).runInTransaction( entityManager -> { diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withhsearch/defaultanalysis/GettingStartedDefaultAnalysisIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withhsearch/defaultanalysis/GettingStartedDefaultAnalysisIT.java index e7d5fbd96ff..0b5e2d9aa66 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withhsearch/defaultanalysis/GettingStartedDefaultAnalysisIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withhsearch/defaultanalysis/GettingStartedDefaultAnalysisIT.java @@ -7,9 +7,8 @@ package org.hibernate.search.documentation.mapper.orm.gettingstarted.withhsearch.defaultanalysis; import static org.assertj.core.api.Assertions.assertThat; -import static org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration.BACKEND_TYPE; +import static org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration.BACKEND_TYPE; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assert.assertEquals; import java.util.List; import java.util.concurrent.atomic.AtomicReference; @@ -26,35 +25,35 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class GettingStartedDefaultAnalysisIT { +class GettingStartedDefaultAnalysisIT { private final String persistenceUnitName = "GettingStartedDefaultAnalysisIT_" + BACKEND_TYPE; private EntityManagerFactory entityManagerFactory; - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = Persistence.createEntityManagerFactory( persistenceUnitName, TestConfiguration.ormMapperProperties( configurationProvider ) ); } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( entityManagerFactory != null ) { entityManagerFactory.close(); } } @Test - public void test() { + void test() { AtomicReference bookIdHolder = new AtomicReference<>(); with( entityManagerFactory ).runInTransaction( entityManager -> { @@ -180,7 +179,7 @@ public void test() { // Not shown: commit the transaction and close the entity manager // end::counting[] - assertEquals( 1L, totalHitCount ); + assertThat( totalHitCount ).isEqualTo( 1L ); } ); } diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withouthsearch/GettingStartedWithoutHibernateSearchIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withouthsearch/GettingStartedWithoutHibernateSearchIT.java index a7aa96bc033..c1a7b5ffac8 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withouthsearch/GettingStartedWithoutHibernateSearchIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/gettingstarted/withouthsearch/GettingStartedWithoutHibernateSearchIT.java @@ -16,28 +16,28 @@ import jakarta.persistence.Persistence; import jakarta.persistence.TypedQuery; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class GettingStartedWithoutHibernateSearchIT { +class GettingStartedWithoutHibernateSearchIT { private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = Persistence.createEntityManagerFactory( "GettingStartedWithoutHibernateSearchIT" ); } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( entityManagerFactory != null ) { entityManagerFactory.close(); } } @Test - public void test() { + void test() { AtomicReference bookIdHolder = new AtomicReference<>(); with( entityManagerFactory ).runInTransaction( entityManager -> { diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/identifiermapping/customtype/IdentifierMappingCustomTypeIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/identifiermapping/customtype/IdentifierMappingCustomTypeIT.java index 8e9026a1580..85fa2e55848 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/identifiermapping/customtype/IdentifierMappingCustomTypeIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/identifiermapping/customtype/IdentifierMappingCustomTypeIT.java @@ -20,23 +20,23 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IdentifierMappingCustomTypeIT { - @Rule +class IdentifierMappingCustomTypeIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( ISBN.parse( "978-0-58-600835-5" ) ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/identifiermapping/naturalid/IdentifierMappingNaturalIdIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/identifiermapping/naturalid/IdentifierMappingNaturalIdIT.java index 69de3a188f5..8c92bf48376 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/identifiermapping/naturalid/IdentifierMappingNaturalIdIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/identifiermapping/naturalid/IdentifierMappingNaturalIdIT.java @@ -17,21 +17,18 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class IdentifierMappingNaturalIdIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class IdentifierMappingNaturalIdIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -41,19 +38,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setIsbn( "9780586008355" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/excludepaths/IndexedEmbeddedExcludePathsIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/excludepaths/IndexedEmbeddedExcludePathsIT.java index 4fb03da9034..b883cadd884 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/excludepaths/IndexedEmbeddedExcludePathsIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/excludepaths/IndexedEmbeddedExcludePathsIT.java @@ -21,24 +21,24 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexedEmbeddedExcludePathsIT { +class IndexedEmbeddedExcludePathsIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Human.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Human human1 = new Human(); human1.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/filteredassociation/FilteredAssociationIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/filteredassociation/FilteredAssociationIT.java index ecb22092a32..11ba3a5b9ff 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/filteredassociation/FilteredAssociationIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/filteredassociation/FilteredAssociationIT.java @@ -17,22 +17,19 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.mapper.pojo.model.path.PojoModelPath; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class FilteredAssociationIT { +class FilteredAssociationIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { // @formatter:off //tag::programmatic[] @@ -53,19 +50,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, BookEdition.class ); } - @Test - public void reindexing() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void reindexing(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setId( 0 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includeembeddedobjectid/IndexedEmbeddedIncludeEmbeddedObjectIdIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includeembeddedobjectid/IndexedEmbeddedIncludeEmbeddedObjectIdIT.java index 670214b230e..e5792a2430b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includeembeddedobjectid/IndexedEmbeddedIncludeEmbeddedObjectIdIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includeembeddedobjectid/IndexedEmbeddedIncludeEmbeddedObjectIdIT.java @@ -18,24 +18,24 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexedEmbeddedIncludeEmbeddedObjectIdIT { +class IndexedEmbeddedIncludeEmbeddedObjectIdIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Employee.class, Department.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Department department1 = new Department(); department1.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includepaths/IndexedEmbeddedIncludePathsIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includepaths/IndexedEmbeddedIncludePathsIT.java index f7a8a48e190..13b843feb75 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includepaths/IndexedEmbeddedIncludePathsIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includepaths/IndexedEmbeddedIncludePathsIT.java @@ -21,24 +21,24 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexedEmbeddedIncludePathsIT { +class IndexedEmbeddedIncludePathsIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Human.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Human human1 = new Human(); human1.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includepathsanddepth/IndexedEmbeddedIncludePathsAndDepthIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includepathsanddepth/IndexedEmbeddedIncludePathsAndDepthIT.java index dc578c510d2..6903dba0473 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includepathsanddepth/IndexedEmbeddedIncludePathsAndDepthIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/includepathsanddepth/IndexedEmbeddedIncludePathsAndDepthIT.java @@ -21,24 +21,24 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexedEmbeddedIncludePathsAndDepthIT { +class IndexedEmbeddedIncludePathsAndDepthIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Human.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Human human1 = new Human(); human1.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/none/IndexedEmbeddedNoneIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/none/IndexedEmbeddedNoneIT.java index f5ababc27a3..1e8b83bf817 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/none/IndexedEmbeddedNoneIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/none/IndexedEmbeddedNoneIT.java @@ -18,24 +18,24 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexedEmbeddedNoneIT { +class IndexedEmbeddedNoneIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/onelevel/IndexedEmbeddedOneLevelIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/onelevel/IndexedEmbeddedOneLevelIT.java index aff688c2829..83889db3164 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/onelevel/IndexedEmbeddedOneLevelIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/onelevel/IndexedEmbeddedOneLevelIT.java @@ -16,22 +16,19 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class IndexedEmbeddedOneLevelIT { +class IndexedEmbeddedOneLevelIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -47,19 +44,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, Author.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/structure/flattened/IndexedEmbeddedStructureFlattenedIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/structure/flattened/IndexedEmbeddedStructureFlattenedIT.java index afce7c82fca..ad892947ee2 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/structure/flattened/IndexedEmbeddedStructureFlattenedIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/structure/flattened/IndexedEmbeddedStructureFlattenedIT.java @@ -17,22 +17,19 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class IndexedEmbeddedStructureFlattenedIT { +class IndexedEmbeddedStructureFlattenedIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { TypeMappingStep bookMapping = mapping.type( Book.class ); bookMapping.indexed(); @@ -48,19 +45,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, Author.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/structure/nested/IndexedEmbeddedStructureNestedIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/structure/nested/IndexedEmbeddedStructureNestedIT.java index ee918e693e2..a48103893f8 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/structure/nested/IndexedEmbeddedStructureNestedIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/structure/nested/IndexedEmbeddedStructureNestedIT.java @@ -17,22 +17,19 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class IndexedEmbeddedStructureNestedIT { +class IndexedEmbeddedStructureNestedIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { TypeMappingStep bookMapping = mapping.type( Book.class ); bookMapping.indexed(); @@ -48,19 +45,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, Author.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/twolevels/IndexedEmbeddedTwoLevelsIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/twolevels/IndexedEmbeddedTwoLevelsIT.java index 70afb708538..0980d6c3a46 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/twolevels/IndexedEmbeddedTwoLevelsIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedembedded/twolevels/IndexedEmbeddedTwoLevelsIT.java @@ -18,24 +18,24 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexedEmbeddedTwoLevelsIT { +class IndexedEmbeddedTwoLevelsIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, Address.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedentities/SearchMappingIndexedEntitiesIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedentities/SearchMappingIndexedEntitiesIT.java index c531d78f317..305aede4f87 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedentities/SearchMappingIndexedEntitiesIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexedentities/SearchMappingIndexedEntitiesIT.java @@ -25,26 +25,26 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.entity.SearchIndexedEntity; import org.hibernate.search.mapper.orm.mapping.SearchMapping; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchMappingIndexedEntitiesIT { +class SearchMappingIndexedEntitiesIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); } @Test - public void indexedEntities() { + void indexedEntities() { //tag::indexedEntities[] SearchMapping mapping = /* ... */ // <1> //end::indexedEntities[] @@ -74,7 +74,7 @@ public void indexedEntities() { } @Test - public void indexMetamodel() { + void indexMetamodel() { SearchMapping mapping = Search.mapping( entityManagerFactory ); //tag::indexMetamodel[] SearchIndexedEntity bookEntity = mapping.indexedEntity( Book.class ); // <1> diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/AbstractHibernateOrmMassIndexingIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/AbstractHibernateOrmMassIndexingIT.java index b3762e86c60..ca4e46b0dc3 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/AbstractHibernateOrmMassIndexingIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/AbstractHibernateOrmMassIndexingIT.java @@ -19,20 +19,20 @@ import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.RegisterExtension; abstract class AbstractHibernateOrmMassIndexingIT { protected static final int NUMBER_OF_BOOKS = 1000; private static final int INIT_DATA_TRANSACTION_SIZE = 500; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); protected EntityManagerFactory entityManagerFactory; - @Before + @BeforeEach public void setup() { this.entityManagerFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.INDEXING_LISTENERS_ENABLED, false ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmIndexingPlanSynchronizationStrategyIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmIndexingPlanSynchronizationStrategyIT.java index 654b9fe80e4..2b444c71e12 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmIndexingPlanSynchronizationStrategyIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmIndexingPlanSynchronizationStrategyIT.java @@ -21,21 +21,21 @@ import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategyNames; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class HibernateOrmIndexingPlanSynchronizationStrategyIT { +class HibernateOrmIndexingPlanSynchronizationStrategyIT { private static final String BOOK1_TITLE = "I, Robot"; private static final String BOOK2_TITLE = "The Caves of Steel"; private static final String BOOK3_TITLE = "The Robots of Dawn"; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); @Test - public void synchronizationStrategyOverride() { + void synchronizationStrategyOverride() { EntityManagerFactory entityManagerFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.INDEXING_PLAN_SYNCHRONIZATION_STRATEGY, diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmJakartaBatchIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmJakartaBatchIT.java index fccb5cf0521..74c5562eed5 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmJakartaBatchIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmJakartaBatchIT.java @@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Properties; @@ -24,24 +24,24 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class HibernateOrmJakartaBatchIT extends AbstractHibernateOrmMassIndexingIT { +class HibernateOrmJakartaBatchIT extends AbstractHibernateOrmMassIndexingIT { private static final int JOB_TIMEOUT_MS = 30_000; private static final int THREAD_SLEEP = 1000; - @Before - public void checkAssumptions() { + @BeforeEach + void checkAssumptions() { assumeTrue( - "This test only makes sense if the backend supports explicit purge", - BackendConfigurations.simple().supportsExplicitPurge() + BackendConfigurations.simple().supportsExplicitPurge(), + "This test only makes sense if the backend supports explicit purge" ); } @Test - public void simple() throws Exception { + void simple() throws Exception { // tag::simple[] Properties jobProps = MassIndexingJob.parameters() // <1> .forEntities( Book.class, Author.class ) // <2> @@ -61,7 +61,7 @@ public void simple() throws Exception { } @Test - public void hql() throws Exception { + void hql() throws Exception { // tag::hql[] Properties jobProps = MassIndexingJob.parameters() // <1> .forEntities( Author.class ) // <2> diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmManualIndexingIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmManualIndexingIT.java index cefe2c5b727..d538ccd3fbc 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmManualIndexingIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmManualIndexingIT.java @@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Arrays; @@ -25,20 +25,20 @@ import org.hibernate.search.mapper.orm.work.SearchIndexingPlan; import org.hibernate.search.mapper.orm.work.SearchWorkspace; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class HibernateOrmManualIndexingIT { +class HibernateOrmManualIndexingIT { private static final int NUMBER_OF_BOOKS = 1000; private static final int BATCH_SIZE = 100; private static final int INIT_DATA_TRANSACTION_SIZE = 500; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); @Test - public void persist_automaticIndexing_periodicFlushClear() { + void persist_automaticIndexing_periodicFlushClear() { EntityManagerFactory entityManagerFactory = setup( true ); with( entityManagerFactory ).runNoTransaction( entityManager -> { @@ -69,7 +69,7 @@ public void persist_automaticIndexing_periodicFlushClear() { } @Test - public void persist_automaticIndexing_periodicFlushExecuteClear() { + void persist_automaticIndexing_periodicFlushExecuteClear() { EntityManagerFactory entityManagerFactory = setup( true ); with( entityManagerFactory ).runNoTransaction( entityManager -> { @@ -104,7 +104,7 @@ public void persist_automaticIndexing_periodicFlushExecuteClear() { } @Test - public void persist_automaticIndexing_multipleTransactions() { + void persist_automaticIndexing_multipleTransactions() { EntityManagerFactory entityManagerFactory = setup( true ); with( entityManagerFactory ).runNoTransaction( entityManager -> { @@ -134,7 +134,7 @@ public void persist_automaticIndexing_multipleTransactions() { } @Test - public void addOrUpdate() { + void addOrUpdate() { int numberOfBooks = 10; EntityManagerFactory entityManagerFactory = setup( false ); initBooksAndAuthors( entityManagerFactory, numberOfBooks ); @@ -167,7 +167,7 @@ public void addOrUpdate() { } @Test - public void delete() { + void delete() { int numberOfBooks = 10; EntityManagerFactory entityManagerFactory = setup( true ); initBooksAndAuthors( entityManagerFactory, numberOfBooks ); @@ -200,7 +200,7 @@ public void delete() { } @Test - public void workspace() { + void workspace() { int numberOfBooks = 10; EntityManagerFactory entityManagerFactory = setup( true ); initBooksAndAuthors( entityManagerFactory, numberOfBooks ); @@ -232,9 +232,11 @@ public void workspace() { } @Test - public void purge() { - assumeTrue( "This test only makes sense if the backend supports explicit purges", - BackendConfigurations.simple().supportsExplicitPurge() ); + void purge() { + assumeTrue( + BackendConfigurations.simple().supportsExplicitPurge(), + "This test only makes sense if the backend supports explicit purges" + ); int numberOfBooks = 10; EntityManagerFactory entityManagerFactory = setup( true ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmMassIndexerIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmMassIndexerIT.java index 4080733430e..b9c2221278b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmMassIndexerIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmMassIndexerIT.java @@ -25,14 +25,14 @@ import org.hibernate.search.util.common.logging.impl.Log; import org.hibernate.search.util.common.logging.impl.LoggerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class HibernateOrmMassIndexerIT extends AbstractHibernateOrmMassIndexingIT { +class HibernateOrmMassIndexerIT extends AbstractHibernateOrmMassIndexingIT { private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() ); @Test - public void simple() { + void simple() { with( entityManagerFactory ).runNoTransaction( entityManager -> { try { // tag::simple[] @@ -55,7 +55,7 @@ public void simple() { } @Test - public void reindexOnly() { + void reindexOnly() { with( entityManagerFactory ).runNoTransaction( entityManager -> { try { // tag::reindexOnly[] @@ -83,7 +83,7 @@ public void reindexOnly() { } @Test - public void selectType() { + void selectType() { with( entityManagerFactory ).runNoTransaction( entityManager -> { try { SearchSession searchSession = Search.session( entityManager ); @@ -103,7 +103,7 @@ public void selectType() { } @Test - public void async_reactive() { + void async_reactive() { with( entityManagerFactory ).runNoTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); CompletionStage completionStage = @@ -130,7 +130,7 @@ public void async_reactive() { } @Test - public void async_future() { + void async_future() { with( entityManagerFactory ).runNoTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::async[] @@ -151,7 +151,7 @@ public void async_future() { } @Test - public void parameters() { + void parameters() { with( entityManagerFactory ).runNoTransaction( entityManager -> { try { SearchSession searchSession = Search.session( entityManager ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmMassIndexerMultiTenancyIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmMassIndexerMultiTenancyIT.java index d57fa243d1b..a0dc426628d 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmMassIndexerMultiTenancyIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/indexing/HibernateOrmMassIndexerMultiTenancyIT.java @@ -22,11 +22,11 @@ import org.hibernate.search.mapper.orm.mapping.SearchMapping; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class HibernateOrmMassIndexerMultiTenancyIT { +class HibernateOrmMassIndexerMultiTenancyIT { private static final String TENANT_1_ID = "tenant1"; private static final String TENANT_2_ID = "tenant2"; @@ -35,13 +35,13 @@ public class HibernateOrmMassIndexerMultiTenancyIT { private static final int NUMBER_OF_BOOKS = 1000; private static final int INIT_DATA_TRANSACTION_SIZE = 500; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { this.sessionFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.INDEXING_LISTENERS_ENABLED, false ) .tenants( TENANT_1_ID, TENANT_2_ID, TENANT_3_ID ) @@ -63,7 +63,7 @@ public void setup() { } @Test - public void explicitTenant() throws InterruptedException { + void explicitTenant() throws InterruptedException { // tag::explicitTenants[] SearchMapping searchMapping = /* ... */ // <1> // end::explicitTenants[] @@ -88,7 +88,7 @@ public void explicitTenant() throws InterruptedException { } @Test - public void implicitTenants() throws InterruptedException { + void implicitTenants() throws InterruptedException { // tag::implicitTenants[] SearchMapping searchMapping = /* ... */ // <1> // end::implicitTenants[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/programmatic/simple/ProgrammaticMappingSimpleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/programmatic/simple/ProgrammaticMappingSimpleIT.java index bbee11b28ae..85e8fe034f6 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/programmatic/simple/ProgrammaticMappingSimpleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/programmatic/simple/ProgrammaticMappingSimpleIT.java @@ -19,19 +19,19 @@ import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProgrammaticMappingSimpleIT { +class ProgrammaticMappingSimpleIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.MAPPING_CONFIGURER, @@ -41,7 +41,7 @@ public void setup() { } @Test - public void simple() { + void simple() { with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/associationinverseside/AssociationInverseSideIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/associationinverseside/AssociationInverseSideIT.java index 6677d2a72b6..977100dcb54 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/associationinverseside/AssociationInverseSideIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/associationinverseside/AssociationInverseSideIT.java @@ -17,24 +17,21 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.extractor.builtin.BuiltinContainerExtractors; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.mapper.pojo.model.path.PojoModelPath; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class AssociationInverseSideIT { +class AssociationInverseSideIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { // @formatter:off //tag::programmatic[] @@ -53,19 +50,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, BookEdition.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setTitle( "The Caves Of Steel" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/derivedfrom/DerivedFromIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/derivedfrom/DerivedFromIT.java index 453afa5f33f..ccd26dbeaf3 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/derivedfrom/DerivedFromIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/derivedfrom/DerivedFromIT.java @@ -16,23 +16,20 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.mapper.pojo.model.path.PojoModelPath; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class DerivedFromIT { +class DerivedFromIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -44,19 +41,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setTitle( "Leviathan Wakes" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/no/correct/ReindexOnUpdateNoIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/no/correct/ReindexOnUpdateNoIT.java index c47113e63f4..ab2f362a42e 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/no/correct/ReindexOnUpdateNoIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/no/correct/ReindexOnUpdateNoIT.java @@ -17,22 +17,19 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ReindexOnUpdateNoIT { +class ReindexOnUpdateNoIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep sensorMapping = mapping.type( Sensor.class ); @@ -48,19 +45,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Sensor.class ); } - @Test - public void reindexOnUpdateNo() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void reindexOnUpdateNo(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { for ( int i = 0; i < 2000; ++i ) { Sensor sensor = new Sensor(); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/no/incorrect/ReindexOnUpdateNoIncorrectIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/no/incorrect/ReindexOnUpdateNoIncorrectIT.java index cb83f91e0f1..9e032092d98 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/no/incorrect/ReindexOnUpdateNoIncorrectIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/no/incorrect/ReindexOnUpdateNoIncorrectIT.java @@ -16,25 +16,25 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ReindexOnUpdateNoIncorrectIT { +class ReindexOnUpdateNoIncorrectIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Sensor.class ); } @Test - public void missingReindexOnUpdateNo() { + void missingReindexOnUpdateNo() { with( entityManagerFactory ).runInTransaction( entityManager -> { for ( int i = 0; i < 2000; ++i ) { Sensor sensor = new Sensor(); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/shallow/correct/ReindexOnUpdateShallowIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/shallow/correct/ReindexOnUpdateShallowIT.java index 5bf6e136321..3d7a3aa6f71 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/shallow/correct/ReindexOnUpdateShallowIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/shallow/correct/ReindexOnUpdateShallowIT.java @@ -17,22 +17,19 @@ import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ReindexOnUpdateShallowIT { +class ReindexOnUpdateShallowIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep bookMapping = mapping.type( Book.class ); @@ -47,19 +44,22 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, BookCategory.class ); } - @Test - public void reindexOnUpdateShallow() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void reindexOnUpdateShallow(Boolean annotationProcessingEnabled, + HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { BookCategory category = new BookCategory(); category.setId( 1 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/shallow/incorrect/ReindexOnUpdateShallowIncorrectIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/shallow/incorrect/ReindexOnUpdateShallowIncorrectIT.java index e1d9b3cbb55..e8e08f090c4 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/shallow/incorrect/ReindexOnUpdateShallowIncorrectIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/reindexing/reindexonupdate/shallow/incorrect/ReindexOnUpdateShallowIncorrectIT.java @@ -13,17 +13,17 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ReindexOnUpdateShallowIncorrectIT { +class ReindexOnUpdateShallowIncorrectIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); @Test - public void missingReindexOnUpdateShallow() { + void missingReindexOnUpdateShallow() { assertThatThrownBy( () -> setupHelper.start().setup( Book.class, BookCategory.class ) ) .isInstanceOf( SearchException.class ) .satisfies( FailureReportUtils.hasFailureReport() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/schema/management/ElasticsearchHibernateOrmSchemaManagerIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/schema/management/ElasticsearchHibernateOrmSchemaManagerIT.java index 7c9b8f58d56..d01121eb90a 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/schema/management/ElasticsearchHibernateOrmSchemaManagerIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/schema/management/ElasticsearchHibernateOrmSchemaManagerIT.java @@ -24,22 +24,22 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.schema.management.SearchSchemaCollector; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.JsonObject; -public class ElasticsearchHibernateOrmSchemaManagerIT { +class ElasticsearchHibernateOrmSchemaManagerIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { this.entityManagerFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.SCHEMA_MANAGEMENT_STRATEGY, @@ -50,7 +50,7 @@ public void setup() { } @Test - public void walkingTheSchemaWithExtension() { + void walkingTheSchemaWithExtension() { with( entityManagerFactory ).runNoTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); SearchSchemaManager schemaManager = searchSession.schemaManager(); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/schema/management/HibernateOrmSchemaManagerIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/schema/management/HibernateOrmSchemaManagerIT.java index c45ce4a3083..cd43347490f 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/schema/management/HibernateOrmSchemaManagerIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/schema/management/HibernateOrmSchemaManagerIT.java @@ -30,26 +30,26 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.schema.management.SearchSchemaCollector; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; -public class HibernateOrmSchemaManagerIT { +class HibernateOrmSchemaManagerIT { private static final int NUMBER_OF_BOOKS = 200; private static final int INIT_DATA_TRANSACTION_SIZE = 100; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); - @Rule - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); + @TempDir + public Path temporaryFolder; private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { this.entityManagerFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.SCHEMA_MANAGEMENT_STRATEGY, SchemaManagementStrategyName.NONE ) @@ -59,7 +59,7 @@ public void setup() { } @Test - public void simple() { + void simple() { with( entityManagerFactory ).runNoTransaction( entityManager -> { try { // tag::simple[] @@ -82,7 +82,7 @@ public void simple() { } @Test - public void selectType() { + void selectType() { with( entityManagerFactory ).runNoTransaction( entityManager -> { try { SearchSession searchSession = Search.session( entityManager ); @@ -102,7 +102,7 @@ public void selectType() { } @Test - public void walkingTheSchema() { + void walkingTheSchema() { with( entityManagerFactory ).runNoTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); List indexNames = new ArrayList<>(); @@ -126,10 +126,10 @@ public void indexSchema(Optional backendName, String indexName, SchemaEx } @Test - public void exportSchemaToFiles() throws IOException { + void exportSchemaToFiles() throws IOException { with( entityManagerFactory ).runNoTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); - Path targetDirectory = temporaryFolder.newFolder().toPath(); + Path targetDirectory = temporaryFolder; // tag::schema-export[] SearchSchemaManager schemaManager = searchSession.schemaManager(); // <1> diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/genericfield/GeoPointGenericFieldIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/genericfield/GeoPointGenericFieldIT.java index 8dd3adb1c8a..8c9f7bc150f 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/genericfield/GeoPointGenericFieldIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/genericfield/GeoPointGenericFieldIT.java @@ -17,22 +17,19 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.spatial.DistanceUnit; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class GeoPointGenericFieldIT { +class GeoPointGenericFieldIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep authorMapping = mapping.type( Author.class ); @@ -43,19 +40,24 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() + ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Author.class, MyCoordinates.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); + with( entityManagerFactory ).runInTransaction( entityManager -> { Author author = new Author(); author.setName( "Isaac Asimov" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/multiple/GeoPointBindingMultipleIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/multiple/GeoPointBindingMultipleIT.java index eca82f55a60..fd82aa51bc7 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/multiple/GeoPointBindingMultipleIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/multiple/GeoPointBindingMultipleIT.java @@ -19,24 +19,24 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class GeoPointBindingMultipleIT { +class GeoPointBindingMultipleIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Author.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Author author = new Author(); author.setName( "Isaac Asimov" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/property/GeoPointBindingPropertyIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/property/GeoPointBindingPropertyIT.java index df96e99a378..db1b8d9280a 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/property/GeoPointBindingPropertyIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/property/GeoPointBindingPropertyIT.java @@ -19,24 +19,24 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class GeoPointBindingPropertyIT { +class GeoPointBindingPropertyIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Author.class, MyCoordinates.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Author author = new Author(); author.setName( "Isaac Asimov" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/type/GeoPointBindingTypeIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/type/GeoPointBindingTypeIT.java index 8bb57a47e48..a3547d5dbfa 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/type/GeoPointBindingTypeIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/orm/spatial/geopointbinding/type/GeoPointBindingTypeIT.java @@ -17,23 +17,20 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.spatial.DistanceUnit; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.bridge.builtin.programmatic.GeoPointBinder; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class GeoPointBindingTypeIT { +class GeoPointBindingTypeIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), mapping -> { //tag::programmatic[] TypeMappingStep authorMapping = mapping.type( Author.class ); @@ -47,19 +44,21 @@ public static List params() { } ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Author.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Author author = new Author(); author.setName( "Isaac Asimov" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/entrypoints/StandalonePojoEntryPointsIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/entrypoints/StandalonePojoEntryPointsIT.java index bd4057b1845..c3d753c489c 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/entrypoints/StandalonePojoEntryPointsIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/entrypoints/StandalonePojoEntryPointsIT.java @@ -20,20 +20,20 @@ import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class StandalonePojoEntryPointsIT { +class StandalonePojoEntryPointsIT { private CloseableSearchMapping theSearchMapping; - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); - @Before - public void setup() { + @BeforeEach + void setup() { // tag::setup[] CloseableSearchMapping searchMapping = SearchMapping.builder() // <1> .property( @@ -55,8 +55,8 @@ public void setup() { this.theSearchMapping = searchMapping; } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( theSearchMapping != null ) { // tag::shutdown[] CloseableSearchMapping searchMapping = /* ... */ // <1> @@ -69,14 +69,14 @@ public void cleanup() { } @Test - public void mappingContainsExpectedEntities() { + void mappingContainsExpectedEntities() { assertThat( theSearchMapping.allIndexedEntities() ) .extracting( SearchIndexedEntity::name ) .contains( "Book", "Associate", "Manager" ); } @Test - public void searchSession() { + void searchSession() { // tag::searchSession-simple[] SearchMapping searchMapping = /* ... */ // <1> // end::searchSession-simple[] @@ -93,7 +93,7 @@ public void searchSession() { } @Test - public void searchSession_withOptions() { + void searchSession_withOptions() { // tag::searchSession-withOptions[] SearchMapping searchMapping = /* ... */ // <1> // end::searchSession-withOptions[] @@ -113,7 +113,7 @@ public void searchSession_withOptions() { } @Test - public void searchScope_fromSearchMapping() { + void searchScope_fromSearchMapping() { SearchMapping searchMapping = theSearchMapping; // tag::searchScope-fromSearchMapping[] SearchScope bookScope = searchMapping.scope( Book.class ); @@ -136,7 +136,7 @@ public void searchScope_fromSearchMapping() { } @Test - public void searchScope_fromSearchSession() { + void searchScope_fromSearchSession() { SearchMapping searchMapping = theSearchMapping; try ( SearchSession searchSession = searchMapping.createSession() ) { SearchScope bookScope = searchSession.scope( Book.class ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/entrypoints/StandalonePojoReadPropertiesFromFileIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/entrypoints/StandalonePojoReadPropertiesFromFileIT.java index a9d62576a23..b991d084740 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/entrypoints/StandalonePojoReadPropertiesFromFileIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/entrypoints/StandalonePojoReadPropertiesFromFileIT.java @@ -21,20 +21,20 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class StandalonePojoReadPropertiesFromFileIT { +class StandalonePojoReadPropertiesFromFileIT { private CloseableSearchMapping theSearchMapping; - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); - @Before - public void setup() throws IOException { + @BeforeEach + void setup() throws IOException { // tag::setup[] try ( Reader propertyFileReader = /* ... */ // <1> @@ -61,8 +61,8 @@ public void setup() throws IOException { // end::setup[] } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( theSearchMapping != null ) { CloseableSearchMapping searchMapping = theSearchMapping; searchMapping.close(); @@ -70,14 +70,14 @@ public void cleanup() { } @Test - public void mappingContainsExpectedEntities() { + void mappingContainsExpectedEntities() { assertThat( theSearchMapping.allIndexedEntities() ) .extracting( SearchIndexedEntity::name ) .contains( "Book", "Associate", "Manager" ); } @Test - public void searchSession() { + void searchSession() { SearchMapping searchMapping = theSearchMapping; try ( SearchSession searchSession = searchMapping.createSession() ) { assertThat( searchSession ).isNotNull(); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/gettingstarted/withhsearch/customanalysis/GettingStartedCustomAnalysisIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/gettingstarted/withhsearch/customanalysis/GettingStartedCustomAnalysisIT.java index 80fcd2d5ac8..060645becc7 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/gettingstarted/withhsearch/customanalysis/GettingStartedCustomAnalysisIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/gettingstarted/withhsearch/customanalysis/GettingStartedCustomAnalysisIT.java @@ -18,22 +18,22 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurer; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class GettingStartedCustomAnalysisIT { +class GettingStartedCustomAnalysisIT { - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); private CloseableSearchMapping searchMapping; - @Before - public void setup() { + @BeforeEach + void setup() { if ( BackendConfiguration.isLucene() ) { // tag::setup-lucene[] CloseableSearchMapping searchMapping = SearchMapping.builder() @@ -80,15 +80,15 @@ else if ( BackendConfiguration.isElasticsearch() ) { } } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( searchMapping != null ) { searchMapping.close(); } } @Test - public void test() { + void test() { Integer bookId = 2; try ( SearchSession session = searchMapping.createSession() ) { Author author = new Author(); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/gettingstarted/withhsearch/defaultanalysis/GettingStartedDefaultAnalysisIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/gettingstarted/withhsearch/defaultanalysis/GettingStartedDefaultAnalysisIT.java index 0484b8d5e4c..8645d401a03 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/gettingstarted/withhsearch/defaultanalysis/GettingStartedDefaultAnalysisIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/gettingstarted/withhsearch/defaultanalysis/GettingStartedDefaultAnalysisIT.java @@ -7,7 +7,6 @@ package org.hibernate.search.documentation.mapper.pojo.standalone.gettingstarted.withhsearch.defaultanalysis; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; import java.util.List; @@ -20,22 +19,22 @@ import org.hibernate.search.mapper.pojo.standalone.scope.SearchScope; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class GettingStartedDefaultAnalysisIT { +class GettingStartedDefaultAnalysisIT { - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); private CloseableSearchMapping searchMapping; - @Before - public void setup() { + @BeforeEach + void setup() { if ( BackendConfiguration.isLucene() ) { // tag::setup-lucene[] CloseableSearchMapping searchMapping = SearchMapping.builder() // <1> @@ -84,15 +83,15 @@ else if ( BackendConfiguration.isElasticsearch() ) { } } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( searchMapping != null ) { searchMapping.close(); } } @Test - public void test() { + void test() { // tag::indexing[] try ( SearchSession session = searchMapping.createSession() ) { // <1> Author author = new Author(); // <2> @@ -192,7 +191,7 @@ public void test() { .fetchTotalHitCount(); // <1> // end::counting[] - assertEquals( 1L, totalHitCount ); + assertThat( totalHitCount ).isEqualTo( 1L ); // tag::counting[] } // end::counting[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/loading/StandalonePojoMassLoadingIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/loading/StandalonePojoMassLoadingIT.java index 97ce4f23dd8..3e55316f359 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/loading/StandalonePojoMassLoadingIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/loading/StandalonePojoMassLoadingIT.java @@ -23,14 +23,14 @@ import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoAssertionHelper; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class StandalonePojoMassLoadingIT { +class StandalonePojoMassLoadingIT { - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); private Map books; @@ -39,8 +39,8 @@ public class StandalonePojoMassLoadingIT { private StandalonePojoAssertionHelper assertions = new StandalonePojoAssertionHelper( BackendConfigurations.simple() ); - @Before - public void setup() { + @BeforeEach + void setup() { Map, Map> entities = new HashMap<>(); books = new LinkedHashMap<>(); entities.put( Book.class, books ); @@ -75,15 +75,15 @@ public void setup() { this.searchMapping = searchMapping; } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( searchMapping != null ) { searchMapping.close(); } } @Test - public void test() throws InterruptedException { + void test() throws InterruptedException { try ( SearchSession searchSession = searchMapping.createSession() ) { assertThat( searchSession.search( Book.class ) .select( f -> f.id( String.class ) ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/loading/StandalonePojoSelectionLoadingIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/loading/StandalonePojoSelectionLoadingIT.java index b382ccff076..0cc8d3a996d 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/loading/StandalonePojoSelectionLoadingIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/loading/StandalonePojoSelectionLoadingIT.java @@ -25,14 +25,14 @@ import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class StandalonePojoSelectionLoadingIT { +class StandalonePojoSelectionLoadingIT { - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); private Map books; @@ -40,8 +40,8 @@ public class StandalonePojoSelectionLoadingIT { private MyDatastore datastore; private CloseableSearchMapping searchMapping; - @Before - public void setup() { + @BeforeEach + void setup() { Map, Map> entities = new HashMap<>(); books = new LinkedHashMap<>(); entities.put( Book.class, books ); @@ -80,15 +80,15 @@ public void setup() { } } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( searchMapping != null ) { searchMapping.close(); } } @Test - public void test() throws InterruptedException { + void test() throws InterruptedException { try ( SearchSession searchSession = searchMapping.createSession() ) { assertThat( searchSession.search( Book.class ) .select( f -> f.id( String.class ) ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/mapping/config/MappingConfigurationIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/mapping/config/MappingConfigurationIT.java index d3cbc879bcf..c413cfd59db 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/mapping/config/MappingConfigurationIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/mapping/config/MappingConfigurationIT.java @@ -22,20 +22,20 @@ import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MappingConfigurationIT { +class MappingConfigurationIT { - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); private CloseableSearchMapping searchMapping; - @Before - public void setup() { + @BeforeEach + void setup() { // tag::setup[] SearchMappingBuilder builder = SearchMapping.builder() // end::setup[] @@ -67,15 +67,15 @@ public void setup() { this.searchMapping = searchMapping; } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( searchMapping != null ) { searchMapping.close(); } } @Test - public void simple() { + void simple() { try ( SearchSession session = searchMapping.createSessionWithOptions() .indexingPlanSynchronizationStrategy( IndexingPlanSynchronizationStrategy.sync() ) .build() ) { diff --git a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/multitenancy/StandalonePojoMultiTenancyIT.java b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/multitenancy/StandalonePojoMultiTenancyIT.java index 45fcc5e4934..dbd156b66ce 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/multitenancy/StandalonePojoMultiTenancyIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/mapper/pojo/standalone/multitenancy/StandalonePojoMultiTenancyIT.java @@ -16,20 +16,20 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class StandalonePojoMultiTenancyIT { +class StandalonePojoMultiTenancyIT { - @Rule + @RegisterExtension public TestConfigurationProvider configurationProvider = new TestConfigurationProvider(); private CloseableSearchMapping theSearchMapping; - @Before - public void setup() { + @BeforeEach + void setup() { // tag::setup[] CloseableSearchMapping searchMapping = SearchMapping.builder() // <1> // ... @@ -46,15 +46,15 @@ public void setup() { this.theSearchMapping = searchMapping; } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( theSearchMapping != null ) { theSearchMapping.close(); } } @Test - public void test() { + void test() { // tag::searchSession[] SearchMapping searchMapping = /* ... */ // <1> // end::searchSession[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/reporting/failurehandler/FailureHandlerIT.java b/documentation/src/test/java/org/hibernate/search/documentation/reporting/failurehandler/FailureHandlerIT.java index 3ecfb54c737..d85b35c3d88 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/reporting/failurehandler/FailureHandlerIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/reporting/failurehandler/FailureHandlerIT.java @@ -16,21 +16,21 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class FailureHandlerIT { +class FailureHandlerIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); - @Rule - public StaticCounters staticCounters = new StaticCounters(); + @RegisterExtension + public StaticCounters staticCounters = StaticCounters.create(); @Test - public void smoke() { + void smoke() { assertThat( staticCounters.get( MyFailureHandler.INSTANCES ) ).isEqualTo( 0 ); setupHelper.start() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/reporting/failurehandler/MyFailureHandler.java b/documentation/src/test/java/org/hibernate/search/documentation/reporting/failurehandler/MyFailureHandler.java index 74194658787..3298cf7f87c 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/reporting/failurehandler/MyFailureHandler.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/reporting/failurehandler/MyFailureHandler.java @@ -11,7 +11,7 @@ import org.hibernate.search.engine.reporting.EntityIndexingFailureContext; import org.hibernate.search.engine.reporting.FailureContext; import org.hibernate.search.engine.reporting.FailureHandler; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; public class MyFailureHandler implements FailureHandler { // end::include[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/aggregation/AggregationDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/aggregation/AggregationDslIT.java index 9968309ea12..05b4e6b1931 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/aggregation/AggregationDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/aggregation/AggregationDslIT.java @@ -32,30 +32,30 @@ import org.hibernate.search.util.common.data.Range; import org.hibernate.search.util.common.data.RangeBoundInclusion; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class AggregationDslIT { +class AggregationDslIT { private static final int BOOK1_ID = 1; private static final int BOOK2_ID = 2; private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, BookEdition.class ); initData(); } @Test - public void entryPoint() { + void entryPoint() { with( entityManagerFactory ).runInTransaction( entityManager -> { // tag::entryPoint-lambdas[] SearchSession searchSession = /* ... */ // <1> @@ -110,7 +110,7 @@ public void entryPoint() { } @Test - public void terms() { + void terms() { withinSearchSession( searchSession -> { // tag::terms[] AggregationKey> countsByGenreKey = AggregationKey.of( "countsByGenre" ); @@ -253,7 +253,7 @@ public void terms() { } @Test - public void range() { + void range() { withinSearchSession( searchSession -> { // tag::range[] AggregationKey, Long>> countsByPriceKey = AggregationKey.of( "countsByPrice" ); @@ -385,7 +385,7 @@ public void range() { } @Test - public void filter() { + void filter() { withinSearchSession( searchSession -> { // tag::filter[] AggregationKey, Long>> countsByPriceKey = AggregationKey.of( "countsByPrice" ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/aggregation/ElasticsearchAggregationDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/aggregation/ElasticsearchAggregationDslIT.java index 54f78adf867..4a5e02cf8f8 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/aggregation/ElasticsearchAggregationDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/aggregation/ElasticsearchAggregationDslIT.java @@ -22,33 +22,33 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.Gson; import com.google.gson.JsonObject; -public class ElasticsearchAggregationDslIT { +class ElasticsearchAggregationDslIT { private static final int BOOK1_ID = 1; private static final int BOOK2_ID = 2; private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, BookEdition.class ); initData(); } @Test - public void elasticsearch() { + void elasticsearch() { withinSearchSession( searchSession -> { // tag::elasticsearch-fromJson-jsonObject[] JsonObject jsonObject = diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/converter/DslConverterIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/converter/DslConverterIT.java index 3aa2b328e8e..47b5bc6ce80 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/converter/DslConverterIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/converter/DslConverterIT.java @@ -28,24 +28,24 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DslConverterIT { - @Rule +class DslConverterIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( AuthenticationEvent.class ); initData(); } @Test - public void dslConverterEnabled() { + void dslConverterEnabled() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -63,7 +63,7 @@ public void dslConverterEnabled() { } @Test - public void dslConverterDisabled() { + void dslConverterDisabled() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/converter/ProjectionConverterIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/converter/ProjectionConverterIT.java index 2871e80bcb1..31faf52ec06 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/converter/ProjectionConverterIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/converter/ProjectionConverterIT.java @@ -28,24 +28,24 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProjectionConverterIT { - @Rule +class ProjectionConverterIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Order.class ); initData(); } @Test - public void projectionConverterEnabled() { + void projectionConverterEnabled() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -62,7 +62,7 @@ public void projectionConverterEnabled() { } @Test - public void projectionConverterDisabled() { + void projectionConverterDisabled() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/highlighting/HighlightingDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/highlighting/HighlightingDslIT.java index d58794c91bd..0415207b8d5 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/highlighting/HighlightingDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/highlighting/HighlightingDslIT.java @@ -24,31 +24,31 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class HighlightingDslIT { +class HighlightingDslIT { private static final int BOOK1_ID = 1; private static final int BOOK2_ID = 2; private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class ); initData(); } @Test - public void entryPoint() { + void entryPoint() { with( entityManagerFactory ).runInTransaction( entityManager -> { // tag::basics[] SearchSession searchSession = /* ... */ // <1> @@ -68,7 +68,7 @@ public void entryPoint() { } @Test - public void composite() { + void composite() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -93,7 +93,7 @@ public void composite() { } @Test - public void veryBasicConfig() { + void veryBasicConfig() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -118,7 +118,7 @@ public void veryBasicConfig() { } @Test - public void basicConfig() { + void basicConfig() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -144,7 +144,7 @@ public void basicConfig() { } @Test - public void variousHighlighterTypesPlain() { + void variousHighlighterTypesPlain() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -163,7 +163,7 @@ public void variousHighlighterTypesPlain() { } @Test - public void variousHighlighterTypesUnified() { + void variousHighlighterTypesUnified() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -182,7 +182,7 @@ public void variousHighlighterTypesUnified() { } @Test - public void variousHighlighterTypesFvh() { + void variousHighlighterTypesFvh() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -202,7 +202,7 @@ public void variousHighlighterTypesFvh() { } @Test - public void basicTags() { + void basicTags() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -222,7 +222,7 @@ public void basicTags() { } @Test - public void fvhTags() { + void fvhTags() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -256,7 +256,7 @@ public void fvhTags() { } @Test - public void fvhSchema() { + void fvhSchema() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -274,7 +274,7 @@ public void fvhSchema() { } @Test - public void fvhSchemaAlternative() { + void fvhSchemaAlternative() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -303,7 +303,7 @@ public void fvhSchemaAlternative() { } @Test - public void encoder() { + void encoder() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -323,7 +323,7 @@ public void encoder() { } @Test - public void noMatchSize() { + void noMatchSize() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -346,7 +346,7 @@ public void noMatchSize() { } @Test - public void fragmentSize() { + void fragmentSize() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -371,7 +371,7 @@ public void fragmentSize() { } @Test - public void order() { + void order() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -397,7 +397,7 @@ public void order() { } @Test - public void fragmenter() { + void fragmenter() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -417,7 +417,7 @@ public void fragmenter() { } @Test - public void scannerDsl() { + void scannerDsl() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -448,7 +448,7 @@ public void scannerDsl() { } @Test - public void scannerLambda() { + void scannerLambda() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -478,7 +478,7 @@ public void scannerLambda() { } @Test - public void scannerCharacters() { + void scannerCharacters() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -507,7 +507,7 @@ public void scannerCharacters() { } @Test - public void phraseLimit() { + void phraseLimit() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/paths/FieldPathsIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/paths/FieldPathsIT.java index 39957ba6484..7836224f52e 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/paths/FieldPathsIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/paths/FieldPathsIT.java @@ -21,11 +21,11 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class FieldPathsIT { +class FieldPathsIT { private static final int BOOK1_ID = 1; private static final int BOOK2_ID = 2; @@ -33,19 +33,19 @@ public class FieldPathsIT { private static final int BOOK4_ID = 4; private static final int BOOK5_ID = 5; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class ); initData(); } @Test - public void root() { + void root() { withinSearchSession( searchSession -> { // tag::root[] List hits = searchSession.search( Book.class ) @@ -60,7 +60,7 @@ public void root() { } @Test - public void nested_implicit() { + void nested_implicit() { withinSearchSession( searchSession -> { // tag::nested_implicit[] List hits = searchSession.search( Book.class ) @@ -75,7 +75,7 @@ public void nested_implicit() { } @Test - public void nested_explicit() { + void nested_explicit() { withinSearchSession( searchSession -> { // tag::nested_explicit[] List hits = searchSession.search( Book.class ) @@ -94,7 +94,7 @@ public void nested_explicit() { } @Test - public void withRoot() { + void withRoot() { withinSearchSession( searchSession -> { // tag::withRoot[] List hits = searchSession.search( Book.class ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/ElasticsearchPredicateDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/ElasticsearchPredicateDslIT.java index 58716312398..bbcd86e7c2e 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/ElasticsearchPredicateDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/ElasticsearchPredicateDslIT.java @@ -20,14 +20,14 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.Gson; import com.google.gson.JsonObject; -public class ElasticsearchPredicateDslIT { +class ElasticsearchPredicateDslIT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -37,19 +37,19 @@ public class ElasticsearchPredicateDslIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } @Test - public void fromJson() { + void fromJson() { withinSearchSession( searchSession -> { // tag::elasticsearch-fromJson-jsonObject[] JsonObject jsonObject = diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/LucenePredicateDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/LucenePredicateDslIT.java index 72b97a71627..06234d90503 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/LucenePredicateDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/LucenePredicateDslIT.java @@ -20,14 +20,14 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.index.Term; import org.apache.lucene.search.RegexpQuery; -public class LucenePredicateDslIT { +class LucenePredicateDslIT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -37,19 +37,19 @@ public class LucenePredicateDslIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } @Test - public void fromLucene() { + void fromLucene() { withinSearchSession( searchSession -> { // tag::lucene-fromLuceneQuery[] List hits = searchSession.search( Book.class ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/PredicateDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/PredicateDslIT.java index d10f0d66274..b27a3f7da8b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/PredicateDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/predicate/PredicateDslIT.java @@ -30,11 +30,11 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.util.common.data.RangeBoundInclusion; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class PredicateDslIT { +class PredicateDslIT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -44,19 +44,19 @@ public class PredicateDslIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } @Test - public void entryPoint() { + void entryPoint() { with( entityManagerFactory ).runInTransaction( entityManager -> { // tag::entryPoint-lambdas[] SearchSession searchSession = /* ... */ // <1> @@ -96,7 +96,7 @@ public void entryPoint() { } @Test - public void matchAll() { + void matchAll() { withinSearchSession( searchSession -> { // tag::matchAll[] List hits = searchSession.search( Book.class ) @@ -124,7 +124,7 @@ public void matchAll() { } @Test - public void matchNone() { + void matchNone() { withinSearchSession( searchSession -> { // tag::matchNone[] List hits = searchSession.search( Book.class ) @@ -138,7 +138,7 @@ public void matchNone() { } @Test - public void id() { + void id() { // DO NOT USE THE BOOKX_ID CONSTANTS INSIDE TAGS BELOW: // we don't want the constants to appear in the documentation. @@ -169,7 +169,7 @@ public void id() { } @Test - public void and() { + void and() { withinSearchSession( searchSession -> { // tag::and[] List hits = searchSession.search( Book.class ) @@ -241,7 +241,7 @@ public void and() { } @Test - public void or() { + void or() { withinSearchSession( searchSession -> { // tag::or[] List hits = searchSession.search( Book.class ) @@ -279,7 +279,7 @@ public void or() { } @Test - public void bool() { + void bool() { withinSearchSession( searchSession -> { // tag::bool-mustNot[] List hits = searchSession.search( Book.class ) @@ -386,7 +386,7 @@ public void bool() { @Test @SuppressWarnings("deprecation") - public void bool_deprecated() { + void bool_deprecated() { withinSearchSession( searchSession -> { // tag::bool-dynamicParameters-deprecated[] MySearchParameters searchParameters = getSearchParameters(); // <1> @@ -415,7 +415,7 @@ public void bool_deprecated() { } @Test - public void match() { + void match() { withinSearchSession( searchSession -> { // tag::match[] List hits = searchSession.search( Book.class ) @@ -430,7 +430,7 @@ public void match() { } @Test - public void match_analysis() { + void match_analysis() { withinSearchSession( searchSession -> { // tag::match-normalized[] List hits = searchSession.search( Author.class ) @@ -457,7 +457,7 @@ public void match_analysis() { } @Test - public void match_fuzzy() { + void match_fuzzy() { withinSearchSession( searchSession -> { // tag::match-fuzzy[] List hits = searchSession.search( Book.class ) @@ -502,7 +502,7 @@ public void match_fuzzy() { } @Test - public void multipleFields() { + void multipleFields() { withinSearchSession( searchSession -> { // tag::multipleFields-fieldOrField[] List hits = searchSession.search( Book.class ) @@ -531,7 +531,7 @@ public void multipleFields() { } @Test - public void overrideAnalysis() { + void overrideAnalysis() { withinSearchSession( searchSession -> { // tag::overrideAnalysis-analyzer[] List hits = searchSession.search( Book.class ) @@ -562,7 +562,7 @@ public void overrideAnalysis() { } @Test - public void score() { + void score() { withinSearchSession( searchSession -> { // tag::score-constantScore[] List hits = searchSession.search( Book.class ) @@ -618,7 +618,7 @@ public void score() { } @Test - public void range() { + void range() { withinSearchSession( searchSession -> { // tag::range-between[] List hits = searchSession.search( Book.class ) @@ -696,7 +696,7 @@ public void range() { } @Test - public void phrase() { + void phrase() { withinSearchSession( searchSession -> { // tag::phrase[] List hits = searchSession.search( Book.class ) @@ -724,7 +724,7 @@ public void phrase() { } @Test - public void simpleQueryString() { + void simpleQueryString() { withinSearchSession( searchSession -> { // tag::simpleQueryString-boolean[] List hits = searchSession.search( Book.class ) @@ -838,7 +838,7 @@ public void simpleQueryString() { } @Test - public void exists() { + void exists() { withinSearchSession( searchSession -> { // tag::exists[] List hits = searchSession.search( Book.class ) @@ -863,7 +863,7 @@ public void exists() { } @Test - public void wildcard() { + void wildcard() { withinSearchSession( searchSession -> { // tag::wildcard[] List hits = searchSession.search( Book.class ) @@ -878,7 +878,7 @@ public void wildcard() { } @Test - public void regexp() { + void regexp() { withinSearchSession( searchSession -> { // tag::regexp[] List hits = searchSession.search( Book.class ) @@ -905,7 +905,7 @@ public void regexp() { } @Test - public void terms_any() { + void terms_any() { withinSearchSession( searchSession -> { // tag::terms-any[] List hits = searchSession.search( Book.class ) @@ -920,7 +920,7 @@ public void terms_any() { } @Test - public void terms_all() { + void terms_all() { withinSearchSession( searchSession -> { // tag::terms-all[] List hits = searchSession.search( Book.class ) @@ -935,7 +935,7 @@ public void terms_all() { } @Test - public void nested() { + void nested() { withinSearchSession( searchSession -> { // tag::nested[] List hits = searchSession.search( Book.class ) @@ -953,7 +953,7 @@ public void nested() { } @Test - public void nested_implicit() { + void nested_implicit() { withinSearchSession( searchSession -> { // tag::nested-implicit-form[] List hits = searchSession.search( Book.class ) @@ -972,7 +972,7 @@ public void nested_implicit() { @Test @SuppressWarnings("deprecation") - public void nested_deprecated() { + void nested_deprecated() { withinSearchSession( searchSession -> { // tag::nested-deprecated[] List hits = searchSession.search( Book.class ) @@ -991,7 +991,7 @@ public void nested_deprecated() { } @Test - public void within() { + void within() { withinSearchSession( searchSession -> { // tag::within-circle[] GeoPoint center = GeoPoint.of( 53.970000, 32.150000 ); @@ -1068,7 +1068,7 @@ public void within() { } @Test - public void not() { + void not() { withinSearchSession( searchSession -> { // tag::not[] List hits = searchSession.search( Book.class ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ElasticsearchProjectionDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ElasticsearchProjectionDslIT.java index 1a3f89a96a6..8c7e2368de2 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ElasticsearchProjectionDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ElasticsearchProjectionDslIT.java @@ -22,15 +22,15 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.JsonObject; import org.skyscreamer.jsonassert.JSONCompareMode; -public class ElasticsearchProjectionDslIT { +class ElasticsearchProjectionDslIT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -40,19 +40,19 @@ public class ElasticsearchProjectionDslIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } @Test - public void source() { + void source() { withinSearchSession( searchSession -> { // tag::elasticsearch-source[] List hits = searchSession.search( Book.class ) @@ -66,7 +66,7 @@ public void source() { } @Test - public void explanation() { + void explanation() { withinSearchSession( searchSession -> { // tag::elasticsearch-explanation[] List hits = searchSession.search( Book.class ) @@ -80,7 +80,7 @@ public void explanation() { } @Test - public void jsonHit() { + void jsonHit() { withinSearchSession( searchSession -> { // tag::elasticsearch-jsonHit[] List hits = searchSession.search( Book.class ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/LuceneProjectionDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/LuceneProjectionDslIT.java index 8105c4fddd7..d1141489650 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/LuceneProjectionDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/LuceneProjectionDslIT.java @@ -20,14 +20,14 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.document.Document; import org.apache.lucene.search.Explanation; -public class LuceneProjectionDslIT { +class LuceneProjectionDslIT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -38,19 +38,19 @@ public class LuceneProjectionDslIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } @Test - public void document() { + void document() { withinSearchSession( searchSession -> { // tag::lucene-document[] List hits = searchSession.search( Book.class ) @@ -64,7 +64,7 @@ public void document() { } @Test - public void explanation() { + void explanation() { withinSearchSession( searchSession -> { // tag::lucene-explanation[] List hits = searchSession.search( Book.class ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java index ec668769ffc..7280a4809de 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java @@ -37,14 +37,14 @@ import org.hibernate.search.mapper.pojo.common.spi.PojoEntityReference; import org.hibernate.search.util.impl.integrationtest.common.assertion.TestComparators; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.Assertions; import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; -public class ProjectionDslIT { +class ProjectionDslIT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -55,19 +55,19 @@ public class ProjectionDslIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } @Test - public void entryPoint() { + void entryPoint() { with( entityManagerFactory ).runInTransaction( entityManager -> { // tag::entryPoint-lambdas[] SearchSession searchSession = /* ... */ // <1> @@ -113,7 +113,7 @@ public void entryPoint() { } @Test - public void documentReference() { + void documentReference() { withinSearchSession( searchSession -> { // tag::documentReference[] List hits = searchSession.search( Book.class ) @@ -132,7 +132,7 @@ public void documentReference() { } @Test - public void reference() { + void reference() { withinSearchSession( searchSession -> { // tag::reference[] List hits = searchSession.search( Book.class ) @@ -150,7 +150,7 @@ public void reference() { } @Test - public void id_object() { + void id_object() { withinSearchSession( searchSession -> { // tag::id-object[] List hits = searchSession.search( Book.class ) @@ -165,7 +165,7 @@ public void id_object() { } @Test - public void id_int() { + void id_int() { withinSearchSession( searchSession -> { // tag::id-int[] List hits = searchSession.search( Book.class ) @@ -180,7 +180,7 @@ public void id_int() { } @Test - public void entity() { + void entity() { withinSearchSession( searchSession -> { // tag::entity[] List hits = searchSession.search( Book.class ) @@ -199,7 +199,7 @@ public void entity() { } @Test - public void entity_requestedType() { + void entity_requestedType() { withinSearchSession( searchSession -> { List hits = searchSession.search( Book.class ) .select( f -> @@ -220,7 +220,7 @@ public void entity_requestedType() { } @Test - public void field() { + void field() { withinSearchSession( searchSession -> { // tag::field[] List hits = searchSession.search( Book.class ) @@ -295,7 +295,7 @@ public void field() { } @Test - public void score() { + void score() { withinSearchSession( searchSession -> { // tag::score[] List hits = searchSession.search( Book.class ) @@ -313,7 +313,7 @@ public void score() { } @Test - public void distance() { + void distance() { withinSearchSession( searchSession -> { // tag::distance[] GeoPoint center = GeoPoint.of( 47.506060, 2.473916 ); @@ -364,7 +364,7 @@ public void distance() { } @Test - public void composite() { + void composite() { withinSearchSession( searchSession -> { // tag::composite-customObject[] List> hits = searchSession.search( Book.class ) @@ -506,7 +506,7 @@ public void composite() { @Test @SuppressWarnings("deprecation") - public void composite_singleStep() { + void composite_singleStep() { withinSearchSession( searchSession -> { // tag::composite-customObject-singlestep[] List> hits = searchSession.search( Book.class ) @@ -572,7 +572,7 @@ public void composite_singleStep() { } @Test - public void object() { + void object() { withinSearchSession( searchSession -> { // tag::object-customObject[] List> hits = searchSession.search( Book.class ) @@ -830,7 +830,7 @@ public void object() { } @Test - public void constant() { + void constant() { withinSearchSession( searchSession -> { // tag::constant-incomposite[] Instant searchRequestTimestamp = Instant.now(); @@ -851,7 +851,7 @@ public void constant() { } @Test - public void highlight() { + void highlight() { withinSearchSession( searchSession -> { // tag::highlight[] List> hits = searchSession.search( Book.class ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/query/ElasticsearchQueryDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/query/ElasticsearchQueryDslIT.java index 90d0a9c1457..3b7423430fc 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/query/ElasticsearchQueryDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/query/ElasticsearchQueryDslIT.java @@ -23,34 +23,34 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -public class ElasticsearchQueryDslIT { +class ElasticsearchQueryDslIT { private static final int BOOK1_ID = 1; private static final int BOOK2_ID = 2; private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start() .setup( Book.class ); initData(); } @Test - public void explain() { + void explain() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::explain-elasticsearch[] @@ -74,7 +74,7 @@ public void explain() { } @Test - public void json() { + void json() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::elasticsearch-requestTransformer[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/query/LuceneQueryDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/query/LuceneQueryDslIT.java index 89f74d6aa28..939058cf78b 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/query/LuceneQueryDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/query/LuceneQueryDslIT.java @@ -19,36 +19,36 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.search.Explanation; import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TopDocs; -public class LuceneQueryDslIT { +class LuceneQueryDslIT { private static final int BOOK1_ID = 1; private static final int BOOK2_ID = 2; private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start() .setup( Book.class ); initData(); } @Test - public void explain() { + void explain() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::explain-lucene[] @@ -74,7 +74,7 @@ public void explain() { } @Test - public void lowLevel() { + void lowLevel() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::lucene-lowLevel[] diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/query/QueryDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/query/QueryDslIT.java index f079b927561..375c4510b58 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/query/QueryDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/query/QueryDslIT.java @@ -38,11 +38,11 @@ import org.hibernate.search.util.common.SearchTimeoutException; import org.hibernate.stat.Statistics; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class QueryDslIT { +class QueryDslIT { private static final int BOOK1_ID = 1; private static final int BOOK2_ID = 2; @@ -54,13 +54,13 @@ public class QueryDslIT { private static final int ASSOCIATE1_ID = 1; private static final int ASSOCIATE2_ID = 2; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start() .withProperty( AvailableSettings.JAKARTA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE.name() ) .setup( Book.class, Manager.class, Associate.class ); @@ -68,7 +68,7 @@ public void setup() { } @Test - public void entryPoint() { + void entryPoint() { with( entityManagerFactory ).runInTransaction( entityManager -> { // tag::entryPoint[] // Not shown: open a transaction if relevant @@ -95,7 +95,7 @@ public void entryPoint() { } @Test - public void targetingMultipleEntityTypes() { + void targetingMultipleEntityTypes() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::targeting-multiple[] @@ -117,7 +117,7 @@ public void targetingMultipleEntityTypes() { } @Test - public void targetingByEntityName() { + void targetingByEntityName() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::targeting-entityName[] @@ -142,7 +142,7 @@ public void targetingByEntityName() { } @Test - public void fetchingBasics() { + void fetchingBasics() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::fetching-searchResult[] @@ -197,7 +197,7 @@ public void fetchingBasics() { } @Test - public void fetchingAllHits() { + void fetchingAllHits() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::fetching-all-searchResult[] @@ -228,7 +228,7 @@ public void fetchingAllHits() { } @Test - public void pagination() { + void pagination() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::fetching-pagination-searchResult[] @@ -256,7 +256,7 @@ public void pagination() { } @Test - public void scrolling() { + void scrolling() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); List collectedIds = new ArrayList<>(); @@ -289,7 +289,7 @@ public void scrolling() { } @Test - public void searchQuery() { + void searchQuery() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::searchQuery[] @@ -322,7 +322,7 @@ public void searchQuery() { } @Test - public void tookAndTimedOut() { + void tookAndTimedOut() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::took-timedOut[] @@ -344,7 +344,7 @@ public void tookAndTimedOut() { } @Test - public void truncateAfter() { + void truncateAfter() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::truncateAfter[] @@ -365,7 +365,7 @@ public void truncateAfter() { } @Test - public void failAfter() { + void failAfter() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::failAfter[] @@ -385,7 +385,7 @@ public void failAfter() { } @Test - public void cacheLookupStrategy() { + void cacheLookupStrategy() { with( entityManagerFactory ).runInTransaction( entityManager -> { Statistics statistics = entityManagerFactory.unwrap( SessionFactory.class ).getStatistics(); statistics.setStatisticsEnabled( true ); @@ -411,7 +411,7 @@ public void cacheLookupStrategy() { } @Test - public void fetchSize() { + void fetchSize() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -430,7 +430,7 @@ public void fetchSize() { } @Test - public void resultTotal() { + void resultTotal() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::fetching-resultTotal[] @@ -453,7 +453,7 @@ public void resultTotal() { } @Test - public void resultTotal_totalHitCountThreshold() { + void resultTotal_totalHitCountThreshold() { with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); // tag::fetching-totalHitCountThreshold[] @@ -473,7 +473,7 @@ public void resultTotal_totalHitCountThreshold() { } @Test - public void graph() { + void graph() { // By default associates are not loaded with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/sort/ElasticsearchSortDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/sort/ElasticsearchSortDslIT.java index fd29a6126cb..aae6e276c95 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/sort/ElasticsearchSortDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/sort/ElasticsearchSortDslIT.java @@ -20,14 +20,14 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.Gson; import com.google.gson.JsonObject; -public class ElasticsearchSortDslIT { +class ElasticsearchSortDslIT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -37,19 +37,19 @@ public class ElasticsearchSortDslIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } @Test - public void fromJson() { + void fromJson() { withinSearchSession( searchSession -> { // tag::elasticsearch-fromJson-jsonObject[] JsonObject jsonObject = diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/sort/LuceneSortDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/sort/LuceneSortDslIT.java index 2ee10ebd5f5..b14fd99ba32 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/sort/LuceneSortDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/sort/LuceneSortDslIT.java @@ -20,14 +20,14 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortedSetSortField; -public class LuceneSortDslIT { +class LuceneSortDslIT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -37,19 +37,19 @@ public class LuceneSortDslIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } @Test - public void fromLucene() { + void fromLucene() { withinSearchSession( searchSession -> { // tag::lucene-fromLuceneSort[] List hits = searchSession.search( Book.class ) diff --git a/documentation/src/test/java/org/hibernate/search/documentation/search/sort/SortDslIT.java b/documentation/src/test/java/org/hibernate/search/documentation/search/sort/SortDslIT.java index f2abc883f3c..9309bdf68c4 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/search/sort/SortDslIT.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/search/sort/SortDslIT.java @@ -24,11 +24,11 @@ import org.hibernate.search.mapper.orm.scope.SearchScope; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SortDslIT { +class SortDslIT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -38,19 +38,19 @@ public class SortDslIT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } @Test - public void entryPoint() { + void entryPoint() { with( entityManagerFactory ).runInTransaction( entityManager -> { // tag::entryPoint-lambdas[] SearchSession searchSession = /* ... */ // <1> @@ -93,7 +93,7 @@ public void entryPoint() { } @Test - public void score() { + void score() { withinSearchSession( searchSession -> { // tag::score[] List hits = searchSession.search( Book.class ) @@ -109,7 +109,7 @@ public void score() { } @Test - public void indexOrder() { + void indexOrder() { withinSearchSession( searchSession -> { // tag::indexOrder[] List hits = searchSession.search( Book.class ) @@ -125,7 +125,7 @@ public void indexOrder() { } @Test - public void stabilization() { + void stabilization() { withinSearchSession( searchSession -> { // tag::stabilization[] List hits = searchSession.search( Book.class ) @@ -140,7 +140,7 @@ public void stabilization() { } @Test - public void field() { + void field() { withinSearchSession( searchSession -> { // tag::field[] List hits = searchSession.search( Book.class ) @@ -155,7 +155,7 @@ public void field() { } @Test - public void order() { + void order() { withinSearchSession( searchSession -> { // tag::order-asc[] List hits = searchSession.search( Book.class ) @@ -194,7 +194,7 @@ public void order() { } @Test - public void missing() { + void missing() { withinSearchSession( searchSession -> { // tag::missing-first[] List hits = searchSession.search( Book.class ) @@ -233,7 +233,7 @@ public void missing() { } @Test - public void mode() { + void mode() { withinSearchSession( searchSession -> { // tag::mode-avg[] List hits = searchSession.search( Author.class ) @@ -248,7 +248,7 @@ public void mode() { } @Test - public void filter() { + void filter() { withinSearchSession( searchSession -> { // tag::filter[] List hits = searchSession.search( Author.class ) @@ -266,7 +266,7 @@ public void filter() { } @Test - public void composite() { + void composite() { withinSearchSession( searchSession -> { // tag::composite[] List hits = searchSession.search( Book.class ) @@ -310,7 +310,7 @@ public void composite() { } @Test - public void then() { + void then() { withinSearchSession( searchSession -> { // tag::then[] List hits = searchSession.search( Book.class ) @@ -326,7 +326,7 @@ public void then() { } @Test - public void distance() { + void distance() { withinSearchSession( searchSession -> { // tag::distance[] GeoPoint center = GeoPoint.of( 47.506060, 2.473916 ); diff --git a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/BackendConfigurations.java b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/BackendConfigurations.java index 55e0f9fe16d..ceb4ffbf722 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/BackendConfigurations.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/BackendConfigurations.java @@ -6,15 +6,15 @@ */ package org.hibernate.search.documentation.testsupport; -import static org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration.BACKEND_TYPE; +import static org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration.BACKEND_TYPE; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchBackendConfiguration; import org.hibernate.search.util.impl.integrationtest.backend.lucene.LuceneBackendConfiguration; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; -import org.hibernate.search.util.impl.integrationtest.common.rule.MappingSetupHelper; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.MappingSetupHelper; public final class BackendConfigurations { diff --git a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/DocumentationSetupHelper.java b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/DocumentationSetupHelper.java index cc2c3aa36db..ac582df3ba8 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/DocumentationSetupHelper.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/DocumentationSetupHelper.java @@ -21,15 +21,17 @@ import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.ProgrammaticMappingConfigurationContext; import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategyNames; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendSetupStrategy; -import org.hibernate.search.util.impl.integrationtest.common.rule.MappingSetupHelper; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendSetupStrategy; +import org.hibernate.search.util.impl.integrationtest.common.extension.MappingSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmAssertionHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.SimpleSessionFactoryBuilder; import org.hibernate.search.util.impl.integrationtest.mapper.orm.multitenancy.impl.MultitenancyTestHelper; +import org.junit.jupiter.params.provider.Arguments; + public final class DocumentationSetupHelper extends MappingSetupHelper { - public static List testParamsForBothAnnotationsAndProgrammatic( - BackendConfiguration backendConfiguration, - Consumer programmaticMappingContributor) { - return testParamsForBothAnnotationsAndProgrammatic( backendConfiguration, - Collections.emptySet(), programmaticMappingContributor ); - } - - public static List testParamsForBothAnnotationsAndProgrammatic( - BackendConfiguration backendConfiguration, - Set> additionalAnnotatedClasses, - Consumer programmaticMappingContributor) { - return testParamsForBothAnnotationsAndProgrammatic( - BackendSetupStrategy.withSingleBackend( backendConfiguration ), - additionalAnnotatedClasses, programmaticMappingContributor ); - } - - public static List testParamsForBothAnnotationsAndProgrammatic( - BackendConfiguration defaultBackendConfiguration, - Map namedBackendConfigurations, - Consumer programmaticMappingContributor) { - return testParamsForBothAnnotationsAndProgrammatic( defaultBackendConfiguration, namedBackendConfigurations, - Collections.emptySet(), programmaticMappingContributor ); - } - - public static List testParamsForBothAnnotationsAndProgrammatic( - BackendConfiguration defaultBackendConfiguration, - Map namedBackendConfigurations, - Set> additionalAnnotatedClasses, - Consumer programmaticMappingContributor) { - return testParamsForBothAnnotationsAndProgrammatic( - BackendSetupStrategy.withMultipleBackends( defaultBackendConfiguration, namedBackendConfigurations ), - additionalAnnotatedClasses, programmaticMappingContributor ); + public static List testParamsForBothAnnotationsAndProgrammatic( + Consumer programmaticMappingContributor + ) { + return testParamsForBothAnnotationsAndProgrammatic( Collections.emptySet(), programmaticMappingContributor ); } - public static List testParamsForBothAnnotationsAndProgrammatic( - BackendSetupStrategy backendSetupStrategy, + public static List testParamsForBothAnnotationsAndProgrammatic( Set> additionalAnnotatedClasses, Consumer programmaticMappingContributor) { - List result = new ArrayList<>(); + List result = new ArrayList<>(); // Annotation-based mapping HibernateOrmSearchMappingConfigurer annotationMappingConfigurer = additionalAnnotatedClasses.isEmpty() ? null : context -> context.annotationMapping().add( additionalAnnotatedClasses ); - result.add( new DocumentationSetupHelper( backendSetupStrategy, - null, annotationMappingConfigurer ) ); + result.add( Arguments.of( null, annotationMappingConfigurer ) ); // Programmatic mapping HibernateOrmSearchMappingConfigurer programmaticMappingConfigurer = context -> programmaticMappingContributor.accept( context.programmaticMapping() ); - result.add( new DocumentationSetupHelper( backendSetupStrategy, - false, programmaticMappingConfigurer ) ); + result.add( Arguments.of( false, programmaticMappingConfigurer ) ); return result; } @@ -106,20 +77,42 @@ public static DocumentationSetupHelper withSingleBackend(BackendConfiguration ba ); } - private final Boolean annotationProcessingEnabled; + public static DocumentationSetupHelper withMultipleBackends(BackendConfiguration defaultBackendConfiguration, + Map namedBackendConfigurations) { + return new DocumentationSetupHelper( + BackendSetupStrategy.withMultipleBackends( defaultBackendConfiguration, namedBackendConfigurations ), + null, null + ); + } - private final HibernateOrmSearchMappingConfigurer defaultMappingConfigurer; - private final OrmAssertionHelper assertionHelper; + private Boolean annotationProcessingEnabled; + private HibernateOrmSearchMappingConfigurer defaultMappingConfigurer; + private OrmAssertionHelper assertionHelper; private DocumentationSetupHelper(BackendSetupStrategy backendSetupStrategy, Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer defaultMappingConfigurer) { - super( backendSetupStrategy ); + super( backendSetupStrategy, Type.METHOD ); this.annotationProcessingEnabled = annotationProcessingEnabled; this.defaultMappingConfigurer = defaultMappingConfigurer; this.assertionHelper = new OrmAssertionHelper( backendSetupStrategy ); } + public DocumentationSetupHelper withMappingConfigurer(HibernateOrmSearchMappingConfigurer defaultMappingConfigurer) { + if ( this.defaultMappingConfigurer != null ) { + throw new IllegalStateException(); + } + this.defaultMappingConfigurer = defaultMappingConfigurer; + + return this; + } + + public DocumentationSetupHelper withAnnotationProcessingEnabled(Boolean annotationProcessingEnabled) { + this.annotationProcessingEnabled = annotationProcessingEnabled; + + return this; + } + @Override public String toString() { return super.toString() diff --git a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/TestConfiguration.java b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/TestConfiguration.java index 57df8825c5e..ab75404ad64 100644 --- a/documentation/src/test/java/org/hibernate/search/documentation/testsupport/TestConfiguration.java +++ b/documentation/src/test/java/org/hibernate/search/documentation/testsupport/TestConfiguration.java @@ -10,7 +10,7 @@ import java.util.Map; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; public final class TestConfiguration { diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/composing/ProjectionBinderComposingIT.java b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/composing/ProjectionBinderComposingIT.java index 4c55f3d60c6..0c20191afa7 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/composing/ProjectionBinderComposingIT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/composing/ProjectionBinderComposingIT.java @@ -18,12 +18,13 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProjectionBinderComposingIT { - @Rule + +class ProjectionBinderComposingIT { + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple(), true, @@ -39,14 +40,14 @@ public class ProjectionBinderComposingIT { private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start() .setup( Book.class, Author.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Author author = new Author(); author.setName( "Isaac Asimov" ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/constructorparameter/ProjectionBinderConstructorParameterIT.java b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/constructorparameter/ProjectionBinderConstructorParameterIT.java index 048129dcef9..c2c2b7b62fa 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/constructorparameter/ProjectionBinderConstructorParameterIT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/constructorparameter/ProjectionBinderConstructorParameterIT.java @@ -12,28 +12,26 @@ import java.util.List; import java.util.stream.Collectors; + import jakarta.persistence.EntityManagerFactory; import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ProjectionBinderConstructorParameterIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class ProjectionBinderConstructorParameterIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), // Since we disable classpath scanning in tests for performance reasons, // we need to register annotated projection types explicitly. // This wouldn't be needed in a typical application. @@ -51,19 +49,21 @@ public static List params() { ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setTitle( "The Caves of Steel" ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/multi/ProjectionBinderMultiIT.java b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/multi/ProjectionBinderMultiIT.java index 64d27492814..dcac9ee0b28 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/multi/ProjectionBinderMultiIT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/multi/ProjectionBinderMultiIT.java @@ -18,22 +18,19 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ProjectionBinderMultiIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class ProjectionBinderMultiIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), // Since we disable classpath scanning in tests for performance reasons, // we need to register annotated projection types explicitly. // This wouldn't be needed in a typical application. @@ -53,19 +50,21 @@ public static List params() { ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setTags( List.of( "robot", "crime" ) ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/param/annotation/ProjectionBinderParamAnnotationIT.java b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/param/annotation/ProjectionBinderParamAnnotationIT.java index 573101755af..1e2f963cace 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/param/annotation/ProjectionBinderParamAnnotationIT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/param/annotation/ProjectionBinderParamAnnotationIT.java @@ -12,28 +12,26 @@ import java.util.List; import java.util.stream.Collectors; + import jakarta.persistence.EntityManagerFactory; import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ProjectionBinderParamAnnotationIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class ProjectionBinderParamAnnotationIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), // Since we disable classpath scanning in tests for performance reasons, // we need to register annotated projection types explicitly. // This wouldn't be needed in a typical application. @@ -53,19 +51,21 @@ public static List params() { ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setTitle( "The Caves of Steel" ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/param/string/ProjectionBinderParamStringIT.java b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/param/string/ProjectionBinderParamStringIT.java index b0d1cdd8b33..f972b45e81f 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/param/string/ProjectionBinderParamStringIT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/param/string/ProjectionBinderParamStringIT.java @@ -19,22 +19,20 @@ import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ProjectionBinderParamStringIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { + +class ProjectionBinderParamStringIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), // Since we disable classpath scanning in tests for performance reasons, // we need to register annotated projection types explicitly. // This wouldn't be needed in a typical application. @@ -54,19 +52,21 @@ public static List params() { ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setTitle( "The Caves of Steel" ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/simple/ProjectionBinderSimpleIT.java b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/simple/ProjectionBinderSimpleIT.java index 62d24cae2a7..3907d196425 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/simple/ProjectionBinderSimpleIT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/binding/projectionbinder/simple/ProjectionBinderSimpleIT.java @@ -12,28 +12,26 @@ import java.util.List; import java.util.stream.Collectors; + import jakarta.persistence.EntityManagerFactory; import org.hibernate.search.documentation.testsupport.BackendConfigurations; import org.hibernate.search.documentation.testsupport.DocumentationSetupHelper; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ProjectionBinderSimpleIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { +class ProjectionBinderSimpleIT { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), // Since we disable classpath scanning in tests for performance reasons, // we need to register annotated projection types explicitly. // This wouldn't be needed in a typical application. @@ -53,19 +51,21 @@ public static List params() { ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class ); } - @Test - public void smoke() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void smoke(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { Book book = new Book(); book.setTitle( "The Caves of Steel" ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/projection/ProjectionConstructorMappingJava17IT.java b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/projection/ProjectionConstructorMappingJava17IT.java index b0c46f8b328..f97c2844691 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/projection/ProjectionConstructorMappingJava17IT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/mapper/orm/projection/ProjectionConstructorMappingJava17IT.java @@ -19,22 +19,21 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.mapper.pojo.search.definition.binding.builtin.IdProjectionBinder; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test that the simple mapping defined in Book works as expected. */ -@RunWith(Parameterized.class) -public class ProjectionConstructorMappingJava17IT { +class ProjectionConstructorMappingJava17IT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -44,15 +43,14 @@ public class ProjectionConstructorMappingJava17IT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Parameterized.Parameters(name = "{0}") - public static List params() { + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), // Since we disable classpath scanning in tests for performance reasons, // we need to register annotated projection types explicitly. // This wouldn't be needed in a typical application. CollectionHelper.asSet( MyBookProjection.class, MyBookProjection.Author.class, - MyAuthorProjectionClassMultiConstructor.class, MyAuthorProjectionRecordMultiConstructor.class ), + MyAuthorProjectionClassMultiConstructor.class, MyAuthorProjectionRecordMultiConstructor.class + ), mapping -> { TypeMappingStep bookMapping = mapping.type( Book.class ); bookMapping.indexed(); @@ -96,20 +94,22 @@ public static List params() { ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; - + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( + BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, Author.class ); initData(); } - @Test - public void simple() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simple(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -171,8 +171,10 @@ public void simple() { } ); } - @Test - public void multiConstructor_class() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiConstructor_class(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -191,8 +193,10 @@ public void multiConstructor_class() { } ); } - @Test - public void multiConstructor_record() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiConstructor_record(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/ProjectionDslJava17IT.java b/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/ProjectionDslJava17IT.java index f69020fb2ca..439cb0c3357 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/ProjectionDslJava17IT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/ProjectionDslJava17IT.java @@ -22,6 +22,7 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.mapper.orm.Search; +import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.common.spi.PojoEntityReference; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; @@ -38,14 +39,16 @@ import org.hibernate.search.util.common.impl.CollectionHelper; import org.hibernate.search.util.impl.integrationtest.common.NormalizationUtils; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -@RunWith(Parameterized.class) -public class ProjectionDslJava17IT { +class ProjectionDslJava17IT { private static final int ASIMOV_ID = 1; private static final int MARTINEZ_ID = 2; @@ -55,10 +58,9 @@ public class ProjectionDslJava17IT { private static final int BOOK3_ID = 3; private static final int BOOK4_ID = 4; - @Parameterized.Parameters(name = "{0}") - public static List params() { + + public static List params() { return DocumentationSetupHelper.testParamsForBothAnnotationsAndProgrammatic( - BackendConfigurations.simple(), // Since we disable classpath scanning in tests for performance reasons, // we need to register annotated projection types explicitly. // This wouldn't be needed in a typical application. @@ -205,20 +207,22 @@ public static List params() { ); } - @Parameterized.Parameter - @Rule - public DocumentationSetupHelper setupHelper; + @RegisterExtension + public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + public void init(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + setupHelper.withAnnotationProcessingEnabled( annotationProcessingEnabled ) + .withMappingConfigurer( mappingContributor ); entityManagerFactory = setupHelper.start().setup( Book.class, Author.class, EmbeddableGeoPoint.class ); initData(); } - @Test - public void entryPoint_mapped_record() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void entryPoint_mapped_record(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -243,8 +247,10 @@ public void entryPoint_mapped_record() { } ); } - @Test - public void composite_mapped_record() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void composite_mapped_record(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); withinSearchSession( searchSession -> { // tag::composite-mapped-record[] List hits = searchSession.search( Book.class ) @@ -260,7 +266,8 @@ public void composite_mapped_record() { book.getId(), book.getTitle(), book.getAuthors().stream() - .map( author -> new MyBookProjection.Author( author.getFirstName(), author.getLastName() ) ) + .map( author -> new MyBookProjection.Author( author.getFirstName(), + author.getLastName() ) ) .collect( Collectors.toList() ) ) ) .collect( Collectors.toList() ) @@ -268,8 +275,10 @@ public void composite_mapped_record() { } ); } - @Test - public void object_mapped_record() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void object_mapped_record(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); withinSearchSession( searchSession -> { // tag::object-mapped-record[] List> hits = searchSession.search( Book.class ) @@ -290,8 +299,10 @@ public void object_mapped_record() { } ); } - @Test - public void projectionConstructor_id() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConstructor_id(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -312,8 +323,10 @@ public void projectionConstructor_id() { } ); } - @Test - public void projectionConstructor_field() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConstructor_field(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -336,8 +349,10 @@ public void projectionConstructor_field() { } ); } - @Test - public void projectionConstructor_score() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConstructor_score(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -361,8 +376,10 @@ public void projectionConstructor_score() { } ); } - @Test - public void projectionConstructor_documentReference() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConstructor_documentReference(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -385,8 +402,10 @@ public void projectionConstructor_documentReference() { } ); } - @Test - public void projectionConstructor_entity() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConstructor_entity(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -409,8 +428,10 @@ public void projectionConstructor_entity() { } ); } - @Test - public void projectionConstructor_entityReference() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConstructor_entityReference(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -432,8 +453,10 @@ public void projectionConstructor_entityReference() { } ); } - @Test - public void projectionConstructor_object() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConstructor_object(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -449,7 +472,8 @@ public void projectionConstructor_object() { book.getAuthors().stream() .map( a -> new MyAuthorProjection( a.getFirstName(), a.getLastName() ) ) .collect( Collectors.toList() ), - new MyAuthorProjection( book.getMainAuthor().getFirstName(), book.getMainAuthor().getLastName() ), + new MyAuthorProjection( book.getMainAuthor().getFirstName(), + book.getMainAuthor().getLastName() ), book.getTitle() ) ) .collect( Collectors.toList() ) @@ -457,8 +481,10 @@ public void projectionConstructor_object() { } ); } - @Test - public void projectionConstructor_composite() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConstructor_composite(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); @@ -479,8 +505,10 @@ public void projectionConstructor_composite() { } ); } - @Test - public void projectionConstructor_highlight() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConstructor_highlight(Boolean annotationProcessingEnabled, HibernateOrmSearchMappingConfigurer mappingContributor) { + init( annotationProcessingEnabled, mappingContributor ); with( entityManagerFactory ).runInTransaction( entityManager -> { SearchSession searchSession = Search.session( entityManager ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/excludepaths/ProjectionConstructorObjectProjectionExcludePathsIT.java b/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/excludepaths/ProjectionConstructorObjectProjectionExcludePathsIT.java index 03d1b231ecc..3569ee78db1 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/excludepaths/ProjectionConstructorObjectProjectionExcludePathsIT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/excludepaths/ProjectionConstructorObjectProjectionExcludePathsIT.java @@ -11,6 +11,7 @@ import java.util.Arrays; import java.util.Collections; + import jakarta.persistence.EntityManagerFactory; import org.hibernate.search.documentation.search.projection.filters.Human; @@ -19,13 +20,13 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProjectionConstructorObjectProjectionExcludePathsIT { +class ProjectionConstructorObjectProjectionExcludePathsIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple(), true, // Since we disable classpath scanning in tests for performance reasons, @@ -36,13 +37,13 @@ public class ProjectionConstructorObjectProjectionExcludePathsIT { private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Human.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Human human1 = new Human(); human1.setId( 1 ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/includepaths/ProjectionConstructorObjectProjectionIncludePathsIT.java b/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/includepaths/ProjectionConstructorObjectProjectionIncludePathsIT.java index 97fe20c602d..4760554d21f 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/includepaths/ProjectionConstructorObjectProjectionIncludePathsIT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/includepaths/ProjectionConstructorObjectProjectionIncludePathsIT.java @@ -19,13 +19,13 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProjectionConstructorObjectProjectionIncludePathsIT { +class ProjectionConstructorObjectProjectionIncludePathsIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple(), true, // Since we disable classpath scanning in tests for performance reasons, @@ -36,13 +36,13 @@ public class ProjectionConstructorObjectProjectionIncludePathsIT { private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Human.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Human human1 = new Human(); human1.setId( 1 ); diff --git a/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/includepathsanddepth/ProjectionConstructorObjectProjectionIncludePathsAndDepthIT.java b/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/includepathsanddepth/ProjectionConstructorObjectProjectionIncludePathsAndDepthIT.java index ff1defa47b6..2214980b6b5 100644 --- a/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/includepathsanddepth/ProjectionConstructorObjectProjectionIncludePathsAndDepthIT.java +++ b/documentation/src/test/java17/org/hibernate/search/documentation/search/projection/filters/includepathsanddepth/ProjectionConstructorObjectProjectionIncludePathsAndDepthIT.java @@ -11,6 +11,7 @@ import java.util.Arrays; import java.util.Collections; + import jakarta.persistence.EntityManagerFactory; import org.hibernate.search.documentation.search.projection.filters.Human; @@ -19,13 +20,13 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProjectionConstructorObjectProjectionIncludePathsAndDepthIT { +class ProjectionConstructorObjectProjectionIncludePathsAndDepthIT { - @Rule + @RegisterExtension public DocumentationSetupHelper setupHelper = DocumentationSetupHelper.withSingleBackend( BackendConfigurations.simple(), true, // Since we disable classpath scanning in tests for performance reasons, @@ -36,13 +37,13 @@ public class ProjectionConstructorObjectProjectionIncludePathsAndDepthIT { private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start().setup( Human.class ); } @Test - public void smoke() { + void smoke() { with( entityManagerFactory ).runInTransaction( entityManager -> { Human human1 = new Human(); human1.setId( 1 ); diff --git a/engine/src/test/java/org/hibernate/search/engine/backend/orchestration/spi/BatchingExecutorTest.java b/engine/src/test/java/org/hibernate/search/engine/backend/orchestration/spi/BatchingExecutorTest.java index c954f258cf0..5c5984bb778 100644 --- a/engine/src/test/java/org/hibernate/search/engine/backend/orchestration/spi/BatchingExecutorTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/backend/orchestration/spi/BatchingExecutorTest.java @@ -11,8 +11,8 @@ import static org.assertj.core.api.Assertions.fail; import static org.awaitility.Awaitility.await; import static org.hibernate.search.util.impl.test.FutureAssert.assertThatFuture; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doThrow; @@ -42,38 +42,37 @@ import org.hibernate.search.engine.reporting.FailureContext; import org.hibernate.search.engine.reporting.FailureHandler; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.awaitility.Awaitility; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings({ "unchecked", "rawtypes" }) // Raw types are the only way to mock parameterized types -@RunWith(Parameterized.class) -public class BatchingExecutorTest { +class BatchingExecutorTest { private static final String NAME = "executor-name"; - @Parameterized.Parameters(name = "operation submitter = {0}") - public static Object[][] params() { - return new Object[][] { - { "BLOCKING", OperationSubmitter.blocking() }, - { "REJECTING", OperationSubmitter.rejecting() }, - { "OFFLOADING", OperationSubmitter.offloading( CompletableFuture::runAsync ) } - }; - } + public static List params() { + List params = new ArrayList<>(); + params.add( Arguments.of( "BLOCKING", OperationSubmitter.blocking() ) ); + params.add( Arguments.of( "REJECTING", OperationSubmitter.rejecting() ) ); + params.add( Arguments.of( "OFFLOADING", OperationSubmitter.offloading( CompletableFuture::runAsync ) ) ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); + return params; + } @Mock private StubWorkProcessor processorMock; @@ -91,20 +90,14 @@ public static Object[][] params() { private ScheduledExecutorService executorService; private BatchingExecutor executor; - private final OperationSubmitter operationSubmitter; - - public BatchingExecutorTest(String name, OperationSubmitter operationSubmitter) { - this.operationSubmitter = operationSubmitter; - } - - @Before - public void setup() { + @BeforeEach + void setup() { mocks.add( processorMock ); mocks.add( failureHandlerMock ); } - @After - public void cleanup() { + @AfterEach + void cleanup() { if ( executorService != null ) { executorService.shutdownNow(); } @@ -113,8 +106,9 @@ public void cleanup() { executor.stop(); } - @Test - public void simple_batchEndsImmediately() throws InterruptedException { + @ParameterizedTest(name = "operation submitter = {0}") + @MethodSource("params") + void simple_batchEndsImmediately(String name, OperationSubmitter operationSubmitter) throws InterruptedException { createAndStartExecutor( 2, true ); StubWork work1Mock = workMock( 1 ); @@ -132,11 +126,13 @@ public void simple_batchEndsImmediately() throws InterruptedException { } ); // Submitting other works should start the executor/processor again - checkPostExecution(); + checkPostExecution( operationSubmitter ); } - @Test - public void simple_batchEndsLater_someAdditionalWorkBeforeComplete() throws InterruptedException { + @ParameterizedTest(name = "operation submitter = {0}") + @MethodSource("params") + void simple_batchEndsLater_someAdditionalWorkBeforeComplete(String name, OperationSubmitter operationSubmitter) + throws InterruptedException { createAndStartExecutor( 2, true ); StubWork work1Mock = workMock( 1 ); @@ -190,11 +186,13 @@ public void simple_batchEndsLater_someAdditionalWorkBeforeComplete() throws Inte } ); // Submitting other works should start the executor/processor again - checkPostExecution(); + checkPostExecution( operationSubmitter ); } - @Test - public void simple_batchEndsLater_noAdditionalWork() throws InterruptedException { + @ParameterizedTest(name = "operation submitter = {0}") + @MethodSource("params") + void simple_batchEndsLater_noAdditionalWork(String name, OperationSubmitter operationSubmitter) + throws InterruptedException { createAndStartExecutor( 2, true ); StubWork work1Mock = workMock( 1 ); @@ -221,16 +219,17 @@ public void simple_batchEndsLater_noAdditionalWork() throws InterruptedException } ); // Submitting other works should start the executor/processor again - checkPostExecution(); + checkPostExecution( operationSubmitter ); } - @Test - public void beginBatchFailure() throws InterruptedException { + @ParameterizedTest(name = "operation submitter = {0}") + @MethodSource("params") + void beginBatchFailure(String name, OperationSubmitter operationSubmitter) throws InterruptedException { createAndStartExecutor( 4, true ); SimulatedFailure simulatedFailure = new SimulatedFailure(); - Runnable unblockExecutorSwitch = blockExecutor(); + Runnable unblockExecutorSwitch = blockExecutor( operationSubmitter ); StubWork work1Mock = workMock( 1 ); executor.submit( work1Mock, operationSubmitter ); @@ -259,16 +258,17 @@ public void beginBatchFailure() throws InterruptedException { .contains( "Executing task '" + NAME + "'" ); // The executor should still try to process submitted works, even after a failure - checkPostExecution(); + checkPostExecution( operationSubmitter ); } - @Test - public void submitFailure() throws InterruptedException { + @ParameterizedTest(name = "operation submitter = {0}") + @MethodSource("params") + void submitFailure(String name, OperationSubmitter operationSubmitter) throws InterruptedException { createAndStartExecutor( 4, true ); SimulatedFailure simulatedFailure = new SimulatedFailure(); - Runnable unblockExecutorSwitch = blockExecutor(); + Runnable unblockExecutorSwitch = blockExecutor( operationSubmitter ); StubWork work1Mock = workMock( 1 ); StubWork work2Mock = workMock( 2 ); @@ -300,16 +300,17 @@ public void submitFailure() throws InterruptedException { } ); // The executor should still try to process submitted works, even after a failure - checkPostExecution(); + checkPostExecution( operationSubmitter ); } - @Test - public void endBatchFailure() throws InterruptedException { + @ParameterizedTest(name = "operation submitter = {0}") + @MethodSource("params") + void endBatchFailure(String name, OperationSubmitter operationSubmitter) throws InterruptedException { createAndStartExecutor( 4, true ); SimulatedFailure simulatedFailure = new SimulatedFailure(); - Runnable unblockExecutorSwitch = blockExecutor(); + Runnable unblockExecutorSwitch = blockExecutor( operationSubmitter ); StubWork work1Mock = workMock( 1 ); StubWork work2Mock = workMock( 2 ); @@ -342,19 +343,15 @@ public void endBatchFailure() throws InterruptedException { .contains( "Executing task '" + NAME + "'" ); // The executor should still try to process submitted works, even after a failure - checkPostExecution(); + checkPostExecution( operationSubmitter ); } @Test - public void simple_newTasksBlockedException() throws InterruptedException { + void simple_newTasksBlockedException() throws InterruptedException { createAndStartExecutor( 2, true ); + OperationSubmitter operationSubmitter = OperationSubmitter.rejecting(); - assumeTrue( - "This test only makes sense for nonblocking submitter", - OperationSubmitter.rejecting().equals( operationSubmitter ) - ); - - Runnable unblockExecutorSwitch = blockExecutor(); + Runnable unblockExecutorSwitch = blockExecutor( operationSubmitter ); StubWork work1Mock = workMock( 1 ); StubWork work2Mock = workMock( 2 ); @@ -378,19 +375,21 @@ public void simple_newTasksBlockedException() throws InterruptedException { } ); // Submitting other works should start the executor/processor again - checkPostExecution(); + checkPostExecution( operationSubmitter ); } - @Test - public void simple_newTasksBlockedWaitAndCompletes() throws InterruptedException { + @ParameterizedTest(name = "operation submitter = {0}") + @MethodSource("params") + void simple_newTasksBlockedWaitAndCompletes(String name, OperationSubmitter operationSubmitter) + throws InterruptedException { createAndStartExecutor( 2, true ); assumeTrue( - "This test only makes sense for blocking submitter", - OperationSubmitter.blocking().equals( operationSubmitter ) + OperationSubmitter.blocking().equals( operationSubmitter ), + "This test only makes sense for blocking submitter" ); - Runnable unblockExecutorSwitch = blockExecutor(); + Runnable unblockExecutorSwitch = blockExecutor( operationSubmitter ); StubWork work1Mock = workMock( 1 ); StubWork work2Mock = workMock( 2 ); @@ -444,21 +443,23 @@ public void simple_newTasksBlockedWaitAndCompletes() throws InterruptedException } ); // Submitting other works should start the executor/processor again - checkPostExecution(); + checkPostExecution( operationSubmitter ); } - @Test - public void simple_newTasksBlockedAndOffloadedCompletes() throws InterruptedException { + @ParameterizedTest(name = "operation submitter = {0}") + @MethodSource("params") + void simple_newTasksBlockedAndOffloadedCompletes(String name, OperationSubmitter operationSubmitter) + throws InterruptedException { AtomicReference offloadAction = new AtomicReference<>( () -> {} ); createAndStartExecutor( 2, true, w -> offloadAction.get().run() ); assumeFalse( - "This test only makes sense for offloading submitter", OperationSubmitter.blocking().equals( operationSubmitter ) - || OperationSubmitter.rejecting().equals( operationSubmitter ) + || OperationSubmitter.rejecting().equals( operationSubmitter ), + "This test only makes sense for offloading submitter" ); - Runnable unblockExecutorSwitch = blockExecutor(); + Runnable unblockExecutorSwitch = blockExecutor( operationSubmitter ); StubWork work1Mock = workMock( 1 ); StubWork work2Mock = workMock( 2 ); @@ -512,7 +513,7 @@ public void simple_newTasksBlockedAndOffloadedCompletes() throws InterruptedExce } ); // Submitting other works should start the executor/processor again - checkPostExecution(); + checkPostExecution( operationSubmitter ); } private void verifyAsynchronouslyAndReset(Consumer verify) { @@ -528,7 +529,7 @@ private void verifyAsynchronouslyAndReset(Consumer verify) { * Block the executor by submitting a batch that will only complete when the returned runnable is executed. * Used to give us the time to carefully craft the next batch with a specific sequence of works. */ - private Runnable blockExecutor() + private Runnable blockExecutor(OperationSubmitter operationSubmitter) throws InterruptedException { StubWork blockingWorkMock = workMock( 0 ); CompletableFuture blockingBatchFuture = new CompletableFuture<>(); @@ -587,7 +588,7 @@ private StubCompletionListener addPendingCompletionListener() { return listener; } - private void checkPostExecution() throws InterruptedException { + private void checkPostExecution(OperationSubmitter operationSubmitter) throws InterruptedException { CompletableFuture completion = executor.completion(); // This should not trigger any call to the mocks verifyNoInteractions( mocks.toArray() ); diff --git a/engine/src/test/java/org/hibernate/search/engine/backend/orchestration/spi/SingletonTaskTest.java b/engine/src/test/java/org/hibernate/search/engine/backend/orchestration/spi/SingletonTaskTest.java index aa5fc6e110b..7c5d31b6ecc 100644 --- a/engine/src/test/java/org/hibernate/search/engine/backend/orchestration/spi/SingletonTaskTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/backend/orchestration/spi/SingletonTaskTest.java @@ -20,12 +20,12 @@ import org.hibernate.search.engine.reporting.FailureHandler; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.awaitility.Awaitility; @TestForIssue(jiraKey = "HSEARCH-4363") -public class SingletonTaskTest { +class SingletonTaskTest { private final TestWorker worker = new TestWorker(); private final TestFailureHandler failureHandler = new TestFailureHandler(); @@ -35,7 +35,7 @@ public class SingletonTaskTest { ); @Test - public void stopWhileBlockingWorkInProgress() throws Exception { + void stopWhileBlockingWorkInProgress() throws Exception { testSubject.ensureScheduled(); Awaitility.await().until( () -> worker.started ); diff --git a/engine/src/test/java/org/hibernate/search/engine/backend/types/converter/FromDocumentFieldValueConverterTest.java b/engine/src/test/java/org/hibernate/search/engine/backend/types/converter/FromDocumentFieldValueConverterTest.java index 06e70875bea..3fdd9e76683 100644 --- a/engine/src/test/java/org/hibernate/search/engine/backend/types/converter/FromDocumentFieldValueConverterTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/backend/types/converter/FromDocumentFieldValueConverterTest.java @@ -15,26 +15,25 @@ import org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentFieldValueConvertContextExtension; import org.hibernate.search.engine.backend.types.converter.runtime.spi.FromDocumentValueConvertContextImpl; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; /** * Test that implementations of the legacy interface {@link FromDocumentFieldValueConverter} * can be used transparently as a {@link FromDocumentValueConverter}. */ +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings("deprecation") -public class FromDocumentFieldValueConverterTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +class FromDocumentFieldValueConverterTest { @Test - public void fromDocumentFieldValue() { + void fromDocumentFieldValue() { BackendSessionContext sessionContextMock = Mockito.mock( BackendSessionContext.class ); FromDocumentValueConvertContextImpl convertContext = new FromDocumentValueConvertContextImpl( sessionContextMock ); @@ -64,7 +63,7 @@ public String convert(Integer value, FromDocumentFieldValueConvertContext contex } @Test - public void isCompatibleWith_default() { + void isCompatibleWith_default() { class DefaultCompatibilityConverter implements FromDocumentFieldValueConverter { @Override public String convert(Integer value, FromDocumentFieldValueConvertContext context) { @@ -82,7 +81,7 @@ public String convert(Integer value, FromDocumentFieldValueConvertContext contex } @Test - public void isCompatibleWith_custom() { + void isCompatibleWith_custom() { class CustomCompatibilityConverter implements FromDocumentFieldValueConverter { @Override public String convert(Integer value, FromDocumentFieldValueConvertContext context) { diff --git a/engine/src/test/java/org/hibernate/search/engine/backend/types/converter/ToDocumentFieldValueConverterTest.java b/engine/src/test/java/org/hibernate/search/engine/backend/types/converter/ToDocumentFieldValueConverterTest.java index 953bc97a09e..fb61b21b6e9 100644 --- a/engine/src/test/java/org/hibernate/search/engine/backend/types/converter/ToDocumentFieldValueConverterTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/backend/types/converter/ToDocumentFieldValueConverterTest.java @@ -15,26 +15,25 @@ import org.hibernate.search.engine.backend.types.converter.runtime.ToDocumentFieldValueConvertContextExtension; import org.hibernate.search.engine.backend.types.converter.runtime.spi.ToDocumentValueConvertContextImpl; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; /** * Test that implementations of the legacy interface {@link ToDocumentFieldValueConverter} * can be used transparently as a {@link ToDocumentValueConverter}. */ +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings("deprecation") -public class ToDocumentFieldValueConverterTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +class ToDocumentFieldValueConverterTest { @Test - public void fromDocumentFieldValue() { + void fromDocumentFieldValue() { BackendMappingContext mappingContextMock = Mockito.mock( BackendMappingContext.class ); ToDocumentValueConvertContextImpl convertContext = new ToDocumentValueConvertContextImpl( mappingContextMock ); @@ -64,7 +63,7 @@ public String convert(Integer value, ToDocumentFieldValueConvertContext context) } @Test - public void isCompatibleWith_default() { + void isCompatibleWith_default() { class DefaultCompatibilityConverter implements ToDocumentFieldValueConverter { @Override public String convert(Integer value, ToDocumentFieldValueConvertContext context) { @@ -82,7 +81,7 @@ public String convert(Integer value, ToDocumentFieldValueConvertContext context) } @Test - public void isCompatibleWith_custom() { + void isCompatibleWith_custom() { class CustomCompatibilityConverter implements ToDocumentFieldValueConverter { @Override public String convert(Integer value, ToDocumentFieldValueConvertContext context) { diff --git a/engine/src/test/java/org/hibernate/search/engine/backend/work/execution/OperationSubmitterExecutorTest.java b/engine/src/test/java/org/hibernate/search/engine/backend/work/execution/OperationSubmitterExecutorTest.java index e0a49b50483..41c2598903a 100644 --- a/engine/src/test/java/org/hibernate/search/engine/backend/work/execution/OperationSubmitterExecutorTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/backend/work/execution/OperationSubmitterExecutorTest.java @@ -23,16 +23,16 @@ import org.hibernate.search.engine.common.execution.spi.SimpleScheduledExecutor; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class OperationSubmitterExecutorTest { +class OperationSubmitterExecutorTest { private SimpleScheduledExecutor executor; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { this.executor = new SimpleScheduledExecutor() { private BlockingQueue queue = new ArrayBlockingQueue<>( 1 ); private ThreadPoolExecutor delegate = new ThreadPoolExecutor( 1, 1, @@ -65,13 +65,13 @@ public boolean isBlocking() { }; } - @After - public void tearDown() throws Exception { + @AfterEach + void tearDown() throws Exception { this.executor.shutdownNow(); } @Test - public void blockingOperationSubmitterBlocksTheOperation() throws InterruptedException { + void blockingOperationSubmitterBlocksTheOperation() throws InterruptedException { BlockingTask blockingTask = new BlockingTask(); executor.submit( blockingTask ); executor.submit( blockingTask ); @@ -99,14 +99,14 @@ public void blockingOperationSubmitterBlocksTheOperation() throws InterruptedExc @Test - public void nonBlockingOperationSubmitterThrowsException() { + void nonBlockingOperationSubmitterThrowsException() { // rejecting submitter would just fail with exception all the time as our executor is blocking assertThatThrownBy( () -> OperationSubmitter.rejecting().submitToExecutor( executor, () -> {}, r -> {}, (e, t) -> {} ) ) .isInstanceOf( RejectedExecutionException.class ); } @Test - public void nonBlockingOperationSubmitterWorksOk() throws InterruptedException { + void nonBlockingOperationSubmitterWorksOk() throws InterruptedException { AtomicBoolean check = new AtomicBoolean( false ); // if executor implements offer() rejecting can finish successfully: OperationSubmitter.rejecting().submitToExecutor( @@ -148,7 +148,7 @@ public Future offer(Runnable task) { } @Test - public void offloadingSubmitterOffloads() throws Exception { + void offloadingSubmitterOffloads() throws Exception { BlockingTask blockingTask = new BlockingTask(); executor.submit( blockingTask ); @@ -161,7 +161,7 @@ public void offloadingSubmitterOffloads() throws Exception { } @Test - public void offloadingSubmitterFailsToOffloadExceptionInProducer() throws Exception { + void offloadingSubmitterFailsToOffloadExceptionInProducer() throws Exception { BlockingTask blockingTask = new BlockingTask(); executor.submit( blockingTask ); @@ -180,7 +180,7 @@ public void offloadingSubmitterFailsToOffloadExceptionInProducer() throws Except } @Test - public void offloadingSubmitterFailsToOffloadExceptionInAction() throws Exception { + void offloadingSubmitterFailsToOffloadExceptionInAction() throws Exception { BlockingTask blockingTask = new BlockingTask(); executor.submit( blockingTask ); diff --git a/engine/src/test/java/org/hibernate/search/engine/backend/work/execution/OperationSubmitterQueueTest.java b/engine/src/test/java/org/hibernate/search/engine/backend/work/execution/OperationSubmitterQueueTest.java index 4fbbc560581..e85fecffb04 100644 --- a/engine/src/test/java/org/hibernate/search/engine/backend/work/execution/OperationSubmitterQueueTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/backend/work/execution/OperationSubmitterQueueTest.java @@ -17,15 +17,15 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class OperationSubmitterQueueTest { +class OperationSubmitterQueueTest { private BlockingQueue queue; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { this.queue = new ArrayBlockingQueue<>( 2 ); OperationSubmitter.blocking().submitToQueue( queue, 1, i -> {}, (e, t) -> {} ); @@ -33,7 +33,7 @@ public void setUp() throws Exception { } @Test - public void blockingOperationSubmitterBlocksTheOperation() throws InterruptedException { + void blockingOperationSubmitterBlocksTheOperation() throws InterruptedException { CompletableFuture future = CompletableFuture.supplyAsync( () -> { try { OperationSubmitter.blocking().submitToQueue( queue, 3, i -> {}, (e, t) -> {} ); @@ -57,14 +57,14 @@ public void blockingOperationSubmitterBlocksTheOperation() throws InterruptedExc @Test - public void nonBlockingOperationSubmitterThrowsException() { + void nonBlockingOperationSubmitterThrowsException() { Integer element = 3; assertThatThrownBy( () -> OperationSubmitter.rejecting().submitToQueue( queue, element, i -> {}, (e, t) -> {} ) ) .isInstanceOf( RejectedExecutionException.class ); } @Test - public void offloadingSubmitterOffloads() throws Exception { + void offloadingSubmitterOffloads() throws Exception { // we won't submit to the queue but just make sure that work got offloaded AtomicBoolean worked = new AtomicBoolean( false ); OperationSubmitter.offloading( Runnable::run ).submitToQueue( queue, 1, i -> { worked.set( true ); }, (e, t) -> {} ); @@ -73,7 +73,7 @@ public void offloadingSubmitterOffloads() throws Exception { } @Test - public void offloadingSubmitterFailsToOffloadExceptionInProducer() throws Exception { + void offloadingSubmitterFailsToOffloadExceptionInProducer() throws Exception { AtomicBoolean worked = new AtomicBoolean( false ); OperationSubmitter.offloading( Runnable::run ).submitToQueue( queue, 1, i -> { throw new IllegalStateException( "fail" ); }, diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/AbstractAllAwareConfigurationPropertySourceTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/AbstractAllAwareConfigurationPropertySourceTest.java index 02a47688553..85451b5fccc 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/AbstractAllAwareConfigurationPropertySourceTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/AbstractAllAwareConfigurationPropertySourceTest.java @@ -16,43 +16,43 @@ import org.hibernate.search.engine.cfg.spi.AllAwareConfigurationPropertySource; -import org.junit.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings("unchecked") public abstract class AbstractAllAwareConfigurationPropertySourceTest { @Test - public void get_missing() { + void get_missing() { ConfigurationPropertySource propertySource = createPropertySource( "ignored", "foo" ); assertThat( propertySource.get( "someKey" ) ).isEmpty(); } @Test - public void get_string() { + void get_string() { ConfigurationPropertySource propertySource = createPropertySource( "someKey", "foo" ); assertThat( (Optional) propertySource.get( "someKey" ) ).contains( "foo" ); } @Test - public void resolve_missing() { + void resolve_missing() { ConfigurationPropertySource propertySource = createPropertySource( "ignored", "foo" ); assertThat( propertySource.resolve( "someKey" ) ).contains( "someKey" ); } @Test - public void resolve_present() { + void resolve_present() { ConfigurationPropertySource propertySource = createPropertySource( "someKey", "foo" ); assertThat( propertySource.resolve( "someKey" ) ).contains( "someKey" ); } @Test - public void resolveAll_empty() { + void resolveAll_empty() { AllAwareConfigurationPropertySource propertySource = createPropertySource( b -> {} ); assertThat( propertySource.resolveAll( (k, v) -> false ) ).isEmpty(); } @Test - public void resolveAll_keyPredicate() { + void resolveAll_keyPredicate() { AllAwareConfigurationPropertySource propertySource = createPropertySource( b -> { b.accept( "someKey.someSubKey1", "foo" ); b.accept( "someKey.someSubKey2", "bar" ); @@ -64,7 +64,7 @@ public void resolveAll_keyPredicate() { } @Test - public void resolveAll_keyAndValuePredicate() { + void resolveAll_keyAndValuePredicate() { AllAwareConfigurationPropertySource propertySource = createPropertySource( b -> { b.accept( "someKey.someSubKey1", "foo" ); b.accept( "someKey.someSubKey2", "bar" ); diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/BackendSettingsTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/BackendSettingsTest.java index 47848de3cc4..d2849b4b0b3 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/BackendSettingsTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/BackendSettingsTest.java @@ -8,12 +8,12 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class BackendSettingsTest { +class BackendSettingsTest { @Test - public void backendKey() { + void backendKey() { assertThat( BackendSettings.backendKey( "foo.bar" ) ) .isEqualTo( "hibernate.search.backend.foo.bar" ); diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/ConfigurationProviderTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/ConfigurationProviderTest.java index 77c211e9368..56204def9a0 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/ConfigurationProviderTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/ConfigurationProviderTest.java @@ -27,20 +27,20 @@ import org.hibernate.search.engine.environment.bean.BeanReference; import org.hibernate.search.engine.environment.bean.BeanResolver; import org.hibernate.search.engine.environment.bean.BeanRetrieval; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; -public class ConfigurationProviderTest { +class ConfigurationProviderTest { - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Test - public void smoke() { + void smoke() { ConfigurationPropertySource propertySource = fromMap( asMap( "someKey", "foo" ) ) .withFallback( fallback( resolver(), global() ) ); assertThat( propertySource.get( "someKey" ) ) @@ -53,7 +53,7 @@ public void smoke() { } @Test - public void scopeChange() { + void scopeChange() { BeanResolver resolver = resolver( scope -> { if ( scope.matchExact( "global" ) ) { @@ -87,7 +87,7 @@ public void scopeChange() { } @Test - public void maskAndFallbackForScope() { + void maskAndFallbackForScope() { BeanResolver resolver = resolver( scope -> { if ( scope.matchExact( "global" ) ) { @@ -120,7 +120,7 @@ public void maskAndFallbackForScope() { } @Test - public void multipleProviders() { + void multipleProviders() { class ConfigurationProviderA implements ConfigurationProvider { @Override @@ -187,7 +187,7 @@ public String toString() { } @Test - public void almostRealisticScenario() { + void almostRealisticScenario() { BeanResolver resolver = resolver( scope -> { if ( scope.matchExact( "global" ) ) { diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/IndexSettingsTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/IndexSettingsTest.java index 31c9ba67c9b..c091ddb2d79 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/IndexSettingsTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/IndexSettingsTest.java @@ -8,12 +8,12 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class IndexSettingsTest { +class IndexSettingsTest { @Test - public void indexKey() { + void indexKey() { assertThat( IndexSettings.indexKey( "indexName", "foo.bar" ) ) .isEqualTo( "hibernate.search.backend.indexes.indexName.foo.bar" ); diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/MapConfigurationPropertySourceTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/MapConfigurationPropertySourceTest.java index 6a0f8455b00..df8a36fd545 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/MapConfigurationPropertySourceTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/MapConfigurationPropertySourceTest.java @@ -14,13 +14,13 @@ import org.hibernate.search.engine.cfg.spi.AllAwareConfigurationPropertySource; -import org.junit.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings("unchecked") -public class MapConfigurationPropertySourceTest extends AbstractAllAwareConfigurationPropertySourceTest { +class MapConfigurationPropertySourceTest extends AbstractAllAwareConfigurationPropertySourceTest { @Test - public void to_string() { + void to_string() { ConfigurationPropertySource propertySource = createPropertySource( "someKey", "foo" ); assertThat( propertySource ).asString() .contains( "Map" ) @@ -28,7 +28,7 @@ public void to_string() { } @Test - public void get_integer() { + void get_integer() { ConfigurationPropertySource propertySource = AllAwareConfigurationPropertySource.fromMap( Collections.singletonMap( "someKey", 42 ) ); diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/SystemConfigurationPropertySourceTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/SystemConfigurationPropertySourceTest.java index 622fa68b89b..03b794f030b 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/SystemConfigurationPropertySourceTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/SystemConfigurationPropertySourceTest.java @@ -17,20 +17,20 @@ import org.hibernate.search.util.impl.test.SystemHelper; import org.hibernate.search.util.impl.test.SystemHelper.SystemPropertyRestorer; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; -public class SystemConfigurationPropertySourceTest extends AbstractAllAwareConfigurationPropertySourceTest { +class SystemConfigurationPropertySourceTest extends AbstractAllAwareConfigurationPropertySourceTest { private final List toClose = new ArrayList<>(); @Test - public void to_string() { + void to_string() { ConfigurationPropertySource propertySource = createPropertySource( "someKey", "foo" ); assertThat( propertySource ).asString().contains( "System" ); } - @After - public void restoreSystemProperties() { + @AfterEach + void restoreSystemProperties() { try ( Closer closer = new Closer<>() ) { closer.pushAll( SystemPropertyRestorer::close, toClose ); } diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyBeanReferenceTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyBeanReferenceTest.java index cb542aa40d0..9721ba33962 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyBeanReferenceTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyBeanReferenceTest.java @@ -27,20 +27,19 @@ import org.hibernate.search.engine.environment.bean.BeanRetrieval; import org.hibernate.search.util.common.SearchException; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Answers; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings({ "unchecked", "rawtypes" }) // Raw types are the only way to mock parameterized types -public class ConfigurationPropertyBeanReferenceTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +class ConfigurationPropertyBeanReferenceTest { @Mock private ConfigurationPropertySource sourceMock; @@ -48,7 +47,7 @@ public class ConfigurationPropertyBeanReferenceTest { private BeanResolver beanResolverMock; @Test - public void withDefault() { + void withDefault() { String key = "withDefault"; ConfigurationProperty> property = ConfigurationProperty.forKey( key ).asBeanReference( StubBean.class ) @@ -117,7 +116,7 @@ public void withDefault() { } @Test - public void withoutDefault() { + void withoutDefault() { String key = "withDefault"; ConfigurationProperty>> property = ConfigurationProperty.forKey( key ).asBeanReference( StubBean.class ) @@ -196,7 +195,7 @@ public void withoutDefault() { } @Test - public void multiValued() { + void multiValued() { String key = "multiValued"; OptionalConfigurationProperty>> property = ConfigurationProperty.forKey( key ).asBeanReference( StubBean.class ) @@ -319,7 +318,7 @@ public void multiValued() { } @Test - public void invalidType() { + void invalidType() { String key = "invalidType"; String resolvedKey = "some.prefix." + key; ConfigurationProperty>> property = @@ -342,7 +341,7 @@ public void invalidType() { } @Test - public void invalidReference() { + void invalidReference() { String key = "invalidReference"; String resolvedKey = "some.prefix." + key; OptionalConfigurationProperty> property = @@ -371,7 +370,7 @@ public void invalidReference() { } @Test - public void multiValued_invalidReference() { + void multiValued_invalidReference() { String key = "multiValued_invalidReference"; String resolvedKey = "some.prefix." + key; OptionalConfigurationProperty>> property = @@ -409,7 +408,7 @@ public void multiValued_invalidReference() { } @Test - public void invalidBeanRetrieval() { + void invalidBeanRetrieval() { String key = "invalidBeanRetrieval"; String resolvedKey = "some.prefix." + key; OptionalConfigurationProperty> property = @@ -445,7 +444,7 @@ public void invalidBeanRetrieval() { } @Test - public void substitute_function() { + void substitute_function() { String key = "substitute_function"; ConfigurationProperty>> property = ConfigurationProperty.forKey( key ).asBeanReference( StubBean.class ) @@ -537,7 +536,7 @@ public void substitute_function() { } @Test - public void substitute_literals() { + void substitute_literals() { String key = "substitute_literals"; ConfigurationProperty>> property = ConfigurationProperty.forKey( key ).asBeanReference( StubBean.class ) diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyInvalidSimpleValuesTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyInvalidSimpleValuesTest.java index 0e8e8b8d306..fa68c089b0b 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyInvalidSimpleValuesTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyInvalidSimpleValuesTest.java @@ -22,23 +22,23 @@ import org.hibernate.search.engine.cfg.ConfigurationPropertySource; import org.hibernate.search.util.common.SearchException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -@RunWith(Parameterized.class) +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings({ "unchecked", "rawtypes" }) // Raw types are the only way to mock parameterized types -public class ConfigurationPropertyInvalidSimpleValuesTest { +class ConfigurationPropertyInvalidSimpleValuesTest { - @Parameterized.Parameters(name = "{1}") - public static Object[][] data() { - return new Object[][] { + public static List params() { + return Arrays.asList( params( KeyContext::asIntegerPositiveOrZeroOrNegative, "foo", 42, "Invalid Integer value: expected either a Number or a String that can be parsed into an Integer.", @@ -89,60 +89,40 @@ MyPropertyType.INVALID_VALUE, new MyPropertyType( "foobar" ), + "' or a String that can be parsed into that type.", MyPropertyType.INVALID_VALUE_ERROR_MESSAGE ) - }; + ); } - private static Object[] params(Function> testedMethod, + private static Arguments params(Function> testedMethod, String invalidStringValue, T validValue, String expectedInvalidValueCommonMessagePrefix, String expectedInvalidStringMessage) { return params( testedMethod, invalidStringValue, validValue, expectedInvalidValueCommonMessagePrefix, - expectedInvalidValueCommonMessagePrefix, expectedInvalidStringMessage ); + expectedInvalidValueCommonMessagePrefix, expectedInvalidStringMessage + ); } - private static Object[] params(Function> testedMethod, + private static Arguments params(Function> testedMethod, String invalidStringValue, T validValue, String expectedInvalidValueTypeMessagePrefix, String expectedInvalidValueStringMessagePrefix, String expectedInvalidStringMessage) { - return new Object[] { - testedMethod, - invalidStringValue, - validValue, - expectedInvalidValueTypeMessagePrefix, - expectedInvalidValueStringMessagePrefix, + return Arguments.of( + testedMethod, invalidStringValue, validValue, + expectedInvalidValueTypeMessagePrefix, expectedInvalidValueStringMessagePrefix, expectedInvalidStringMessage - }; + ); } - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private ConfigurationPropertySource sourceMock; - private final Function> testedMethod; - private final String invalidStringValue; - private final T validValue; - private final String expectedInvalidValueTypeMessagePrefix; - private final String expectedInvalidValueStringMessagePrefix; - private final String expectedInvalidStringMessage; - - public ConfigurationPropertyInvalidSimpleValuesTest(Function> testedMethod, + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void withDefault(Function> testedMethod, String invalidStringValue, T validValue, String expectedInvalidValueTypeMessagePrefix, String expectedInvalidValueStringMessagePrefix, String expectedInvalidStringMessage) { - this.testedMethod = testedMethod; - this.invalidStringValue = invalidStringValue; - this.validValue = validValue; - this.expectedInvalidValueTypeMessagePrefix = expectedInvalidValueTypeMessagePrefix; - this.expectedInvalidValueStringMessagePrefix = expectedInvalidValueStringMessagePrefix; - this.expectedInvalidStringMessage = expectedInvalidStringMessage; - } - - @Test - public void withDefault() { String key = "withDefault"; String resolvedKey = "some.prefix." + key; ConfigurationProperty property = @@ -175,8 +155,13 @@ public void withDefault() { verifyNoOtherSourceInteractionsAndReset(); } - @Test - public void withoutDefault() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void withoutDefault(Function> testedMethod, + String invalidStringValue, T validValue, + String expectedInvalidValueTypeMessagePrefix, + String expectedInvalidValueStringMessagePrefix, + String expectedInvalidStringMessage) { String key = "withoutDefault"; String resolvedKey = "some.prefix." + key; ConfigurationProperty> property = @@ -208,8 +193,13 @@ public void withoutDefault() { verifyNoOtherSourceInteractionsAndReset(); } - @Test - public void multiValued() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void multiValued(Function> testedMethod, + String invalidStringValue, T validValue, + String expectedInvalidValueTypeMessagePrefix, + String expectedInvalidValueStringMessagePrefix, + String expectedInvalidStringMessage) { String key = "multiValued"; String resolvedKey = "some.prefix." + key; ConfigurationProperty>> property = diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyValidMissingValuesTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyValidMissingValuesTest.java index 6e608a2eb35..7a88dbdfc99 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyValidMissingValuesTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyValidMissingValuesTest.java @@ -23,23 +23,23 @@ import org.hibernate.search.engine.cfg.ConfigurationPropertySource; import org.hibernate.search.util.common.SearchException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -@RunWith(Parameterized.class) +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings({ "unchecked", "rawtypes" }) // Raw types are the only way to mock parameterized types -public class ConfigurationPropertyValidMissingValuesTest { +class ConfigurationPropertyValidMissingValuesTest { - @Parameterized.Parameters(name = "{2}") - public static Object[][] data() { - return new Object[][] { + public static List params() { + return Arrays.asList( params( KeyContext::asString, "string", "string" ), params( KeyContext::asIntegerPositiveOrZeroOrNegative, "42", 42 ), params( KeyContext::asIntegerPositiveOrZeroOrNegative, "0", 0 ), @@ -54,35 +54,23 @@ public static Object[][] data() { c -> c.as( MyPropertyType.class, MyPropertyType::new ), "string", new MyPropertyType( "string" ) ) - }; + ); } - private static Object[] params(Function> testedMethod, + private static Arguments params(Function> testedMethod, String stringValue, T expectedValue) { - return new Object[] { testedMethod, stringValue, expectedValue }; + return Arguments.of( testedMethod, stringValue, expectedValue ); } - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private ConfigurationPropertySource sourceMock; @Mock private Function mappingFunction; - private final Function> testedMethod; - private final String stringValue; - private final T expectedValue; - - public ConfigurationPropertyValidMissingValuesTest(Function> testedMethod, + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void withDefault(Function> testedMethod, String stringValue, T expectedValue) { - this.testedMethod = testedMethod; - this.stringValue = stringValue; - this.expectedValue = expectedValue; - } - - @Test - public void withDefault() { String key = "withDefault"; ConfigurationProperty property = testedMethod.apply( @@ -112,8 +100,10 @@ public void withDefault() { assertThat( result ).isEqualTo( expectedValue ); } - @Test - public void withoutDefault() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void withoutDefault(Function> testedMethod, + String stringValue, T expectedValue) { String key = "withoutDefault"; ConfigurationProperty> property = testedMethod.apply( @@ -142,8 +132,10 @@ public void withoutDefault() { assertThat( result ).contains( expectedValue ); } - @Test - public void withoutDefault_getAndMap() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void withoutDefault_getAndMap(Function> testedMethod, + String stringValue, T expectedValue) { String key = "withoutDefault_getAndMap"; String resolvedKey = "some.prefix." + key; OptionalConfigurationProperty property = @@ -184,8 +176,10 @@ public void withoutDefault_getAndMap() { verifyNoOtherSourceInteractionsAndReset(); } - @Test - public void withoutDefault_getOrThrow() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void withoutDefault_getOrThrow(Function> testedMethod, + String stringValue, T expectedValue) { String key = "withoutDefault_getOrThrow"; String resolvedKey = "some.prefix." + key; OptionalConfigurationProperty property = @@ -211,8 +205,10 @@ public void withoutDefault_getOrThrow() { assertThat( result ).isEqualTo( expectedValue ); } - @Test - public void withoutDefault_getAndMapOrThrow() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void withoutDefault_getAndMapOrThrow(Function> testedMethod, + String stringValue, T expectedValue) { String key = "withoutDefault_getAndMapOrThrow"; String resolvedKey = "some.prefix." + key; OptionalConfigurationProperty property = @@ -255,8 +251,10 @@ public void withoutDefault_getAndMapOrThrow() { verifyNoOtherSourceInteractionsAndReset(); } - @Test - public void blankCharacters() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void blankCharacters(Function> testedMethod, + String stringValue, T expectedValue) { String key = "extraBlankCharacters"; ConfigurationProperty property = testedMethod.apply( @@ -286,8 +284,10 @@ public void blankCharacters() { assertThat( result ).isEqualTo( expectedValue ); } - @Test - public void multiValued() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void multiValued(Function> testedMethod, + String stringValue, T expectedValue) { String key = "multiValued"; ConfigurationProperty>> property = testedMethod.apply( diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyValidSimpleValuesTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyValidSimpleValuesTest.java index 1aad177ed64..21e387b0a2b 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyValidSimpleValuesTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ConfigurationPropertyValidSimpleValuesTest.java @@ -23,23 +23,23 @@ import org.hibernate.search.engine.cfg.ConfigurationPropertySource; import org.hibernate.search.util.common.SearchException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -@RunWith(Parameterized.class) +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings({ "unchecked", "rawtypes" }) // Raw types are the only way to mock parameterized types -public class ConfigurationPropertyValidSimpleValuesTest { +class ConfigurationPropertyValidSimpleValuesTest { - @Parameterized.Parameters(name = "{2}") - public static Object[][] data() { - return new Object[][] { + public static List params() { + return Arrays.asList( params( KeyContext::asString, "string", "string" ), params( KeyContext::asIntegerPositiveOrZeroOrNegative, "42", 42 ), params( KeyContext::asIntegerPositiveOrZeroOrNegative, "0", 0 ), @@ -54,33 +54,21 @@ public static Object[][] data() { c -> c.as( MyPropertyType.class, MyPropertyType::new ), "string", new MyPropertyType( "string" ) ) - }; + ); } - private static Object[] params(Function> testedMethod, + private static Arguments params(Function> testedMethod, String stringValue, T expectedValue) { - return new Object[] { testedMethod, stringValue, expectedValue }; + return Arguments.of( testedMethod, stringValue, expectedValue ); } - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private ConfigurationPropertySource sourceMock; - private final Function> testedMethod; - private final String stringValue; - private final T expectedValue; - - public ConfigurationPropertyValidSimpleValuesTest(Function> testedMethod, + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void withDefault(Function> testedMethod, String stringValue, T expectedValue) { - this.testedMethod = testedMethod; - this.stringValue = stringValue; - this.expectedValue = expectedValue; - } - - @Test - public void withDefault() { String key = "withDefault"; ConfigurationProperty property = testedMethod.apply( @@ -110,8 +98,10 @@ public void withDefault() { assertThat( result ).isEqualTo( expectedValue ); } - @Test - public void withoutDefault() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void withoutDefault(Function> testedMethod, + String stringValue, T expectedValue) { String key = "withoutDefault"; ConfigurationProperty> property = testedMethod.apply( @@ -140,8 +130,10 @@ public void withoutDefault() { assertThat( result ).contains( expectedValue ); } - @Test - public void withoutDefault_getOrThrow() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void withoutDefault_getOrThrow(Function> testedMethod, + String stringValue, T expectedValue) { String key = "withoutDefault_getOrThrow"; String resolvedKey = "some.prefix." + key; OptionalConfigurationProperty property = @@ -167,8 +159,10 @@ public void withoutDefault_getOrThrow() { assertThat( result ).isEqualTo( expectedValue ); } - @Test - public void multiValued() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void multiValued(Function> testedMethod, + String stringValue, T expectedValue) { String key = "multiValued"; ConfigurationProperty>> property = testedMethod.apply( @@ -214,8 +208,10 @@ public void multiValued() { assertThat( result.get() ).containsExactly( expectedValue, expectedValue ); } - @Test - public void substitute_function() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void substitute_function(Function> testedMethod, + String stringValue, T expectedValue) { String key = "substitute_function"; OptionalConfigurationProperty property = testedMethod.apply( ConfigurationProperty.forKey( key ) ) .substitute( v -> { @@ -258,8 +254,10 @@ public void substitute_function() { assertThat( result ).contains( expectedValue ); } - @Test - public void substitute_literals() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void substitute_literals(Function> testedMethod, + String stringValue, T expectedValue) { String key = "substitute_literals"; OptionalConfigurationProperty property = testedMethod.apply( ConfigurationProperty.forKey( key ) ) .substitute( MyEnum.VALUE1, expectedValue ) @@ -292,8 +290,10 @@ public void substitute_literals() { assertThat( result ).contains( expectedValue ); } - @Test - public void substitute_literals_withDefault() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void substitute_literals_withDefault(Function> testedMethod, + String stringValue, T expectedValue) { String key = "substitute_literals_withDefault"; ConfigurationProperty property = testedMethod.apply( ConfigurationProperty.forKey( key ) ) .substitute( MyEnum.VALUE1, expectedValue ) @@ -327,8 +327,10 @@ public void substitute_literals_withDefault() { assertThat( result ).isEqualTo( expectedValue ); } - @Test - public void substitute_literals_multiValued() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void substitute_literals_multiValued(Function> testedMethod, + String stringValue, T expectedValue) { String key = "substitute_literals_multiValued"; OptionalConfigurationProperty> property = testedMethod.apply( ConfigurationProperty.forKey( key ) ) .substitute( MyEnum.VALUE1, expectedValue ) diff --git a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ParseUtilsTest.java b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ParseUtilsTest.java index 48357c05268..6d819fd8b99 100644 --- a/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ParseUtilsTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/cfg/spi/ParseUtilsTest.java @@ -13,12 +13,12 @@ import org.hibernate.search.engine.spatial.GeoPoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ParseUtilsTest { +class ParseUtilsTest { @Test - public void parseYear() { + void parseYear() { assertThat( ParseUtils.parseYear( "2001" ) ).isEqualTo( Year.of( 2001 ) ); assertThat( ParseUtils.parseYear( "1999" ) ).isEqualTo( Year.of( 1999 ) ); assertThat( ParseUtils.parseYear( "1769" ) ).isEqualTo( Year.of( 1769 ) ); @@ -34,7 +34,7 @@ public void parseYear() { } @Test - public void parseGeoPoint() { + void parseGeoPoint() { GeoPoint geoPoint = ParseUtils.parseGeoPoint( "12.123, -24.234" ); assertThat( geoPoint ).isEqualTo( GeoPoint.of( 12.123, -24.234 ) ); diff --git a/engine/src/test/java/org/hibernate/search/engine/common/dsl/impl/DslExtensionStateTest.java b/engine/src/test/java/org/hibernate/search/engine/common/dsl/impl/DslExtensionStateTest.java index 020914497e9..c5f343e4920 100644 --- a/engine/src/test/java/org/hibernate/search/engine/common/dsl/impl/DslExtensionStateTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/common/dsl/impl/DslExtensionStateTest.java @@ -19,18 +19,17 @@ import org.hibernate.search.engine.common.dsl.spi.DslExtensionState; import org.hibernate.search.util.common.SearchException; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class DslExtensionStateTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class DslExtensionStateTest { @Mock private Function contextFunction; @@ -40,14 +39,14 @@ public class DslExtensionStateTest { private final MyResultType expectedResult = new MyResultType(); @Test - public void ifSupported_noSupported() { + void ifSupported_noSupported() { String extensionToString = "EXTENSION_TO_STRING"; state.ifSupported( new MyExtension( extensionToString ), Optional.empty(), contextFunction ); verifyNoOtherInteractionsAndReset(); } @Test - public void ifSupported_supported() { + void ifSupported_supported() { Object extendedContext = new Object(); when( contextFunction.apply( extendedContext ) ).thenReturn( expectedResult ); @@ -56,7 +55,7 @@ public void ifSupported_supported() { } @Test - public void orElse() { + void orElse() { Object defaultContext = new Object(); when( contextFunction.apply( defaultContext ) ).thenReturn( expectedResult ); @@ -65,7 +64,7 @@ public void orElse() { } @Test - public void orElseFail() { + void orElseFail() { assertThatThrownBy( state::orElseFail ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -75,7 +74,7 @@ public void orElseFail() { } @Test - public void ifSupportedThenOrElseFail_noSupported() { + void ifSupportedThenOrElseFail_noSupported() { String extensionToString = "EXTENSION_TO_STRING"; state.ifSupported( new MyExtension( extensionToString ), Optional.empty(), contextFunction ); assertThatThrownBy( state::orElseFail ) @@ -88,7 +87,7 @@ public void ifSupportedThenOrElseFail_noSupported() { } @Test - public void ifSupportedThenOrElseFail_supported() { + void ifSupportedThenOrElseFail_supported() { Object extendedContext = new Object(); when( contextFunction.apply( extendedContext ) ).thenReturn( expectedResult ); @@ -100,7 +99,7 @@ public void ifSupportedThenOrElseFail_supported() { } @Test - public void ifSupportedThenOrElse_noSupported() { + void ifSupportedThenOrElse_noSupported() { Object defaultContext = new Object(); state.ifSupported( new MyExtension(), Optional.empty(), contextFunction ); @@ -112,7 +111,7 @@ public void ifSupportedThenOrElse_noSupported() { } @Test - public void ifSupportedThenOrElse_supported() { + void ifSupportedThenOrElse_supported() { Object extendedContext = new Object(); Object defaultContext = new Object(); @@ -125,7 +124,7 @@ public void ifSupportedThenOrElse_supported() { } @Test - public void multipleIfSupported_noSupported() { + void multipleIfSupported_noSupported() { String extension1ToString = "EXTENSION1_TO_STRING"; String extension2ToString = "EXTENSION2_TO_STRING"; String extension3ToString = "EXTENSION3_TO_STRING"; @@ -145,7 +144,7 @@ public void multipleIfSupported_noSupported() { } @Test - public void multipleIfSupported_singleSupported() { + void multipleIfSupported_singleSupported() { Object extendedContext1 = new Object(); when( contextFunction.apply( extendedContext1 ) ).thenReturn( expectedResult ); @@ -163,7 +162,7 @@ public void multipleIfSupported_singleSupported() { } @Test - public void multipleIfSupported_multipleSupported() { + void multipleIfSupported_multipleSupported() { Object extendedContext2 = new Object(); Object extendedContext3 = new Object(); @@ -183,7 +182,7 @@ public void multipleIfSupported_multipleSupported() { } @Test - public void multipleIfSupportedThenOrElse_noSupported() { + void multipleIfSupportedThenOrElse_noSupported() { Object defaultContext = new Object(); state.ifSupported( new MyExtension(), Optional.empty(), contextFunction ); @@ -201,7 +200,7 @@ public void multipleIfSupportedThenOrElse_noSupported() { } @Test - public void multipleIfSupportedThenOrElse_singleSupported() { + void multipleIfSupportedThenOrElse_singleSupported() { Object extendedContext1 = new Object(); Object defaultContext = new Object(); @@ -220,7 +219,7 @@ public void multipleIfSupportedThenOrElse_singleSupported() { } @Test - public void multipleIfSupportedThenOrElse_multipleSupported() { + void multipleIfSupportedThenOrElse_multipleSupported() { Object extendedContext2 = new Object(); Object extendedContext3 = new Object(); Object defaultContext = new Object(); @@ -241,7 +240,7 @@ public void multipleIfSupportedThenOrElse_multipleSupported() { } @Test - public void orElseThenIfSupported() { + void orElseThenIfSupported() { Object defaultContext = new Object(); when( contextFunction.apply( defaultContext ) ).thenReturn( expectedResult ); diff --git a/engine/src/test/java/org/hibernate/search/engine/common/impl/IndexManagerBuildingStateHolderTest.java b/engine/src/test/java/org/hibernate/search/engine/common/impl/IndexManagerBuildingStateHolderTest.java index 93193d57b5f..e9a2ae60957 100644 --- a/engine/src/test/java/org/hibernate/search/engine/common/impl/IndexManagerBuildingStateHolderTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/common/impl/IndexManagerBuildingStateHolderTest.java @@ -7,7 +7,7 @@ package org.hibernate.search.engine.common.impl; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; @@ -36,27 +36,27 @@ import org.hibernate.search.engine.reporting.spi.FailureCollector; import org.hibernate.search.engine.tenancy.spi.TenancyMode; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Answers; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; // We have to use raw types to mock methods returning generic types with wildcards +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings({ "unchecked", "rawtypes" }) -public class IndexManagerBuildingStateHolderTest { +class IndexManagerBuildingStateHolderTest { - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - - @Rule + @RegisterExtension public final ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Mock @@ -88,8 +88,8 @@ public class IndexManagerBuildingStateHolderTest { private final List verifiedMocks = new ArrayList<>(); - @Before - public void setup() { + @BeforeEach + void setup() { Collections.addAll( verifiedMocks, rootFailureCollectorMock, backendFailureCollectorMock, backendFactoryMock, backendMock, indexManagerBuilderMock, indexRootBuilderMock @@ -97,7 +97,7 @@ public void setup() { } @Test - public void defaultBackend_noNameSet() { + void defaultBackend_noNameSet() { ArgumentCaptor backendPropertySourceCapture = ArgumentCaptor.forClass( ConfigurationPropertySource.class ); ArgumentCaptor indexPropertySourceCapture = @@ -160,7 +160,7 @@ public void defaultBackend_noNameSet() { } @Test - public void explicitBackend() { + void explicitBackend() { ArgumentCaptor backendPropertySourceCapture = ArgumentCaptor.forClass( ConfigurationPropertySource.class ); ArgumentCaptor indexPropertySourceCapture = @@ -230,7 +230,7 @@ public void explicitBackend() { } @Test - public void error_missingBackendType_nullType() { + void error_missingBackendType_nullType() { String keyPrefix = "somePrefix."; ArgumentCaptor throwableCaptor = ArgumentCaptor.forClass( Throwable.class ); @@ -259,11 +259,12 @@ public void error_missingBackendType_nullType() { "Unable to resolve backend type", "configuration property 'somePrefix.backend.type' is not set," + " and there isn't any backend in the classpath", - "Check that you added the desired backend to your project's dependencies" ); + "Check that you added the desired backend to your project's dependencies" + ); } @Test - public void error_missingBackendType_emptyType() { + void error_missingBackendType_emptyType() { String keyPrefix = "somePrefix."; ArgumentCaptor throwableCaptor = ArgumentCaptor.forClass( Throwable.class ); @@ -292,11 +293,12 @@ public void error_missingBackendType_emptyType() { "Unable to resolve backend type", "configuration property 'somePrefix.backend.type' is not set," + " and there isn't any backend in the classpath", - "Check that you added the desired backend to your project's dependencies" ); + "Check that you added the desired backend to your project's dependencies" + ); } @Test - public void differentTenancyModeNamedBackend() { + void differentTenancyModeNamedBackend() { assertThatThrownBy( () -> { BackendsInfo result = new BackendsInfo(); result.collect( Optional.of( "backend-name" ), TenancyMode.MULTI_TENANCY ); @@ -307,7 +309,7 @@ public void differentTenancyModeNamedBackend() { } @Test - public void differentTenancyModeDefaultBackend() { + void differentTenancyModeDefaultBackend() { assertThatThrownBy( () -> { BackendsInfo result = new BackendsInfo(); result.collect( Optional.empty(), TenancyMode.SINGLE_TENANCY ); diff --git a/engine/src/test/java/org/hibernate/search/engine/common/impl/SearchIntegrationImplTest.java b/engine/src/test/java/org/hibernate/search/engine/common/impl/SearchIntegrationImplTest.java index cdebf0256bd..c8cd5280f6d 100644 --- a/engine/src/test/java/org/hibernate/search/engine/common/impl/SearchIntegrationImplTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/common/impl/SearchIntegrationImplTest.java @@ -28,21 +28,20 @@ import org.hibernate.search.engine.reporting.FailureHandler; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class SearchIntegrationImplTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class SearchIntegrationImplTest { @Mock private BeanProvider beanProviderMock; @@ -79,8 +78,8 @@ public class SearchIntegrationImplTest { private SearchIntegrationImpl searchIntegration; - @Before - public void setup() { + @BeforeEach + void setup() { Map, MappingImplementor> mappings = new LinkedHashMap<>(); mappings.put( mappingKey( "mapping1" ), mapping1Mock ); mappings.put( mappingKey( "mapping2" ), mapping2Mock ); @@ -98,7 +97,7 @@ public void setup() { } @Test - public void close_success() { + void close_success() { when( mapping1Mock.preStop( any() ) ).thenReturn( CompletableFuture.completedFuture( null ) ); when( mapping2Mock.preStop( any() ) ).thenReturn( CompletableFuture.completedFuture( null ) ); when( indexManager1Mock.preStop() ).thenReturn( CompletableFuture.completedFuture( null ) ); @@ -145,7 +144,7 @@ public void close_success() { } @Test - public void close_failure() { + void close_failure() { when( mapping1Mock.preStop( any() ) ).thenReturn( failedFuture( "mapping1 preStop failure" ) ); when( mapping2Mock.preStop( any() ) ).thenThrow( exception( "mapping2 preStop failure" ) ); doThrow( exception( "mapping1 stop failure" ) ).when( mapping1Mock ).stop(); diff --git a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplBaseTest.java b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplBaseTest.java index 27b1d29ad34..944dc11dde4 100644 --- a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplBaseTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplBaseTest.java @@ -32,19 +32,18 @@ import org.hibernate.search.engine.environment.classpath.spi.ServiceResolver; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class BeanResolverImplBaseTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class BeanResolverImplBaseTest { @Mock private ClassResolver classResolverMock; @@ -77,7 +76,7 @@ public class BeanResolverImplBaseTest { private BeanResolver beanResolver; - @Before + @BeforeEach // Raw types are the only way to set the return value for a wildcard return type (Optional) @SuppressWarnings({ "unchecked", "rawtypes" }) public void setup() { @@ -110,7 +109,7 @@ public void setup() { } @Test - public void resolve_matchingConfiguredBeans() { + void resolve_matchingConfiguredBeans() { BeanHolder type1BeanHolder = BeanHolder.of( new InternalType1() ); BeanHolder type2BeanHolder = BeanHolder.of( new InternalType2() ); BeanHolder type3BeanHolder1 = BeanHolder.of( new InternalType3() ); @@ -151,7 +150,7 @@ public void resolve_matchingConfiguredBeans() { } @Test - public void resolve_matchingBeanManager_beanName() { + void resolve_matchingBeanManager_beanName() { BeanHolder type1BeanHolder = BeanHolder.of( new BeanManagerType1() ); BeanHolder type2BeanHolder = BeanHolder.of( new BeanManagerType2() ); BeanHolder type3BeanHolder1 = BeanHolder.of( new BeanManagerType3() ); @@ -196,7 +195,7 @@ public void resolve_matchingBeanManager_beanName() { } @Test - public void resolve_matchingBeanManager_className() { + void resolve_matchingBeanManager_className() { BeanHolder type1BeanHolder = BeanHolder.of( new BeanManagerType1() ); BeanHolder type2BeanHolder = BeanHolder.of( new BeanManagerType2() ); BeanHolder type3BeanHolder1 = BeanHolder.of( new BeanManagerType3() ); @@ -250,7 +249,7 @@ public void resolve_matchingBeanManager_className() { } @Test - public void resolve_matchingReflection() { + void resolve_matchingReflection() { BeanNotFoundException beanManagerNotFoundException = new BeanNotFoundException( "cannot find from beanManager" ); // resolve(Class) @@ -304,7 +303,7 @@ public void resolve_matchingReflection() { } @Test - public void resolve_noMatch() { + void resolve_noMatch() { BeanNotFoundException beanManagerNotFoundException = new BeanNotFoundException( "cannot find from beanManager" ); RuntimeException classNotFoundException = new RuntimeException( "cannot find class" ); @@ -383,7 +382,7 @@ public void resolve_noMatch() { } @Test - public void resolve_configuredBeanFactoryFailure() { + void resolve_configuredBeanFactoryFailure() { RuntimeException beanFactoryFailure = new RuntimeException( "internal failure in factory" ); // resolve(Class) @@ -402,7 +401,7 @@ public void resolve_configuredBeanFactoryFailure() { } @Test - public void resolve_beanManagerFailure() { + void resolve_beanManagerFailure() { RuntimeException beanManagerFailure = new RuntimeException( "internal failure in provider" ); // resolve(Class) @@ -420,7 +419,7 @@ public void resolve_beanManagerFailure() { } @Test - public void resolve_ambiguousInternalBean() { + void resolve_ambiguousInternalBean() { BeanNotFoundException beanManagerNotFoundException = new BeanNotFoundException( "cannot find from beanManager" ); // resolve(Class) @@ -438,7 +437,7 @@ public void resolve_ambiguousInternalBean() { } @Test - public void resolveRole() { + void resolveRole() { BeanHolder beanHolder1 = BeanHolder.of( new InternalType3() ); BeanHolder beanHolder2 = BeanHolder.of( new InternalType3() ); BeanHolder beanHolder3 = BeanHolder.of( new InternalType3() ); diff --git a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalBeanTest.java b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalBeanTest.java index 6bfbf1dab33..56c9ca4a0ca 100644 --- a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalBeanTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalBeanTest.java @@ -31,19 +31,18 @@ import org.hibernate.search.engine.environment.classpath.spi.ServiceResolver; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class BeanResolverImplRetrievalBeanTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class BeanResolverImplRetrievalBeanTest { @Mock private ClassResolver classResolverMock; @@ -68,7 +67,7 @@ public class BeanResolverImplRetrievalBeanTest { private BeanResolver beanResolver; - @Before + @BeforeEach // Raw types are the only way to set the return value for a wildcard return type (Optional) @SuppressWarnings({ "unchecked", "rawtypes" }) public void setup() { @@ -96,7 +95,7 @@ public void setup() { } @Test - public void resolve_matchingBeanManager() { + void resolve_matchingBeanManager() { BeanHolder type1BeanHolder = BeanHolder.of( new BeanManagerType1() ); BeanHolder type2BeanHolder = BeanHolder.of( new BeanManagerType2() ); BeanHolder type3BeanHolder1 = BeanHolder.of( new BeanManagerType3() ); @@ -142,7 +141,7 @@ public void resolve_matchingBeanManager() { } @Test - public void resolve_noMatch() { + void resolve_noMatch() { BeanNotFoundException beanManagerNotFoundException = new BeanNotFoundException( "cannot find from beanManager" ); // resolve(Class) @@ -205,7 +204,7 @@ public void resolve_noMatch() { } @Test - public void resolve_beanManagerFailure() { + void resolve_beanManagerFailure() { RuntimeException beanManagerFailure = new RuntimeException( "internal failure in provider" ); // resolve(Class) diff --git a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalBuiltinTest.java b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalBuiltinTest.java index a707d81d283..2f5f97dcf19 100644 --- a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalBuiltinTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalBuiltinTest.java @@ -30,19 +30,18 @@ import org.hibernate.search.engine.environment.classpath.spi.ServiceResolver; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class BeanResolverImplRetrievalBuiltinTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class BeanResolverImplRetrievalBuiltinTest { @Mock private ClassResolver classResolverMock; @@ -67,7 +66,7 @@ public class BeanResolverImplRetrievalBuiltinTest { private BeanResolver beanResolver; - @Before + @BeforeEach // Raw types are the only way to set the return value for a wildcard return type (Optional) @SuppressWarnings({ "unchecked", "rawtypes" }) public void setup() { @@ -94,7 +93,7 @@ public void setup() { } @Test - public void resolve_matchingConfiguredBeans() { + void resolve_matchingConfiguredBeans() { BeanHolder type1BeanHolder = BeanHolder.of( new InternalType1() ); BeanHolder type2BeanHolder = BeanHolder.of( new InternalType2() ); BeanHolder type3BeanHolder1 = BeanHolder.of( new InternalType3() ); @@ -136,7 +135,7 @@ public void resolve_matchingConfiguredBeans() { } @Test - public void resolve_noMatch() { + void resolve_noMatch() { // resolve(Class) assertThatThrownBy( () -> beanResolver.resolve( InvalidType.class, BeanRetrieval.BUILTIN ) ) .isInstanceOf( SearchException.class ) @@ -180,7 +179,7 @@ public void resolve_noMatch() { } @Test - public void resolve_configuredBeanFactoryFailure() { + void resolve_configuredBeanFactoryFailure() { RuntimeException beanFactoryFailure = new RuntimeException( "internal failure in factory" ); // resolve(Class) @@ -199,7 +198,7 @@ public void resolve_configuredBeanFactoryFailure() { } @Test - public void resolve_ambiguousInternalBean() { + void resolve_ambiguousInternalBean() { // resolve(Class) assertThatThrownBy( () -> beanResolver.resolve( InternalType3.class, BeanRetrieval.BUILTIN ) ) .isInstanceOf( SearchException.class ) diff --git a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalClassTest.java b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalClassTest.java index 4aa7f6e824a..c422dd4b50f 100644 --- a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalClassTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalClassTest.java @@ -32,19 +32,18 @@ import org.hibernate.search.engine.environment.classpath.spi.ServiceResolver; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class BeanResolverImplRetrievalClassTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class BeanResolverImplRetrievalClassTest { @Mock private ClassResolver classResolverMock; @@ -69,7 +68,7 @@ public class BeanResolverImplRetrievalClassTest { private BeanResolver beanResolver; - @Before + @BeforeEach // Raw types are the only way to set the return value for a wildcard return type (Optional) @SuppressWarnings({ "unchecked", "rawtypes" }) public void setup() { @@ -97,7 +96,7 @@ public void setup() { } @Test - public void resolve_matchingBeanManager() { + void resolve_matchingBeanManager() { BeanHolder type1BeanHolder = BeanHolder.of( new BeanManagerType1() ); BeanHolder type2BeanHolder = BeanHolder.of( new BeanManagerType2() ); BeanHolder type3BeanHolder1 = BeanHolder.of( new BeanManagerType3() ); @@ -146,7 +145,7 @@ public void resolve_matchingBeanManager() { } @Test - public void resolve_matchingReflection() { + void resolve_matchingReflection() { BeanNotFoundException beanManagerNotFoundException = new BeanNotFoundException( "cannot find from beanManager" ); // resolve(Class) @@ -195,7 +194,7 @@ public void resolve_matchingReflection() { } @Test - public void resolve_noMatch() { + void resolve_noMatch() { BeanNotFoundException beanManagerNotFoundException = new BeanNotFoundException( "cannot find from beanManager" ); RuntimeException classNotFoundException = new RuntimeException( "cannot find class" ); @@ -265,7 +264,7 @@ public void resolve_noMatch() { } @Test - public void resolve_beanManagerFailure() { + void resolve_beanManagerFailure() { RuntimeException beanManagerFailure = new RuntimeException( "internal failure in provider" ); // resolve(Class) diff --git a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalConstructorTest.java b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalConstructorTest.java index 46b43149b40..9e0017f5b82 100644 --- a/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalConstructorTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/environment/bean/impl/BeanResolverImplRetrievalConstructorTest.java @@ -31,19 +31,18 @@ import org.hibernate.search.engine.environment.classpath.spi.ServiceResolver; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class BeanResolverImplRetrievalConstructorTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class BeanResolverImplRetrievalConstructorTest { @Mock private ClassResolver classResolverMock; @@ -68,7 +67,7 @@ public class BeanResolverImplRetrievalConstructorTest { private BeanResolver beanResolver; - @Before + @BeforeEach // Raw types are the only way to set the return value for a wildcard return type (Optional) @SuppressWarnings({ "unchecked", "rawtypes" }) public void setup() { @@ -96,7 +95,7 @@ public void setup() { } @Test - public void resolve_matchingReflection() { + void resolve_matchingReflection() { // resolve(Class) assertThat( beanResolver.resolve( ReflectionType1.class, BeanRetrieval.CONSTRUCTOR ) ) .extracting( BeanHolder::get ).isInstanceOf( ReflectionType1.class ); @@ -133,7 +132,7 @@ public void resolve_matchingReflection() { } @Test - public void resolve_noMatch() { + void resolve_noMatch() { RuntimeException classNotFoundException = new RuntimeException( "cannot find class" ); // resolve(Class) diff --git a/engine/src/test/java/org/hibernate/search/engine/mapper/mapping/building/impl/TreeNestingContextTest.java b/engine/src/test/java/org/hibernate/search/engine/mapper/mapping/building/impl/TreeNestingContextTest.java index ff3aa4a7e61..40ab77e6b7c 100644 --- a/engine/src/test/java/org/hibernate/search/engine/mapper/mapping/building/impl/TreeNestingContextTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/mapper/mapping/building/impl/TreeNestingContextTest.java @@ -9,10 +9,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.common.impl.CollectionHelper.asSet; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; @@ -37,18 +33,20 @@ import org.hibernate.search.util.common.reporting.EventContext; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class TreeNestingContextTest { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class TreeNestingContextTest { private static final BiFunction CYCLIC_RECURSION_EXCEPTION_FACTORY = (mappingElement, cyclicRecursionPath) -> new SearchException( cyclicRecursionMessage( mappingElement, cyclicRecursionPath ) ); @@ -57,9 +55,6 @@ private static String cyclicRecursionMessage(MappingElement mappingElement, Stri return "Cyclic recursion! Root = " + mappingElement.toString() + ", path = " + cyclicRecursionPath; } - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock(strictness = Mock.Strictness.LENIENT) private MappableTypeModel typeModel1Mock; @@ -84,8 +79,8 @@ private static String cyclicRecursionMessage(MappingElement mappingElement, Stri @Mock private TreeNestingContext.NestedContextBuilder nestedContextBuilderMock; - @Before - public void setup() { + @BeforeEach + void setup() { when( typeModel1Mock.name() ).thenReturn( "typeModel1Mock" ); when( typeModel2Mock.name() ).thenReturn( "typeModel2Mock" ); when( typeModel3Mock.name() ).thenReturn( "typeModel3Mock" ); @@ -93,7 +88,7 @@ public void setup() { } @Test - public void noFilter() { + void noFilter() { TreeNestingContext rootContext = TreeNestingContext.root(); checkFooBarIncluded( "", rootContext ); @@ -105,7 +100,7 @@ public void noFilter() { } @Test - public void nestComposed_noFilter() { + void nestComposed_noFilter() { TreeNestingContext rootContext = TreeNestingContext.root(); TreeNestingContext level1Context = checkSimpleComposedFilterIncluded( @@ -130,7 +125,7 @@ public void nestComposed_noFilter() { } @Test - public void nestComposed_noFilter_detectCycle_direct() { + void nestComposed_noFilter_detectCycle_direct() { TreeNestingContext rootContext = TreeNestingContext.root(); String relativePrefix = "level1.prefix1_"; @@ -160,7 +155,7 @@ public void nestComposed_noFilter_detectCycle_direct() { } @Test - public void nestComposed_noFilter_detectCycle_indirect() { + void nestComposed_noFilter_detectCycle_indirect() { TreeNestingContext rootContext = TreeNestingContext.root(); String level1RelativePrefix = "level1.prefix1_"; @@ -192,7 +187,7 @@ level1Definition, new TreeFilterPathTracker( level1Definition ), } @Test - public void nestComposed_noFilter_multiLevelPrefix() { + void nestComposed_noFilter_multiLevelPrefix() { TreeNestingContext rootContext = TreeNestingContext.root(); ArgumentCaptor nestedContextCapture = @@ -219,9 +214,9 @@ relativePrefix, definition, new TreeFilterPathTracker( definition ), inOrder.verify( nestedContextBuilderMock ).appendObject( "level3" ); inOrder.verify( nestedContextBuilderMock ).build( nestedContextCapture.capture() ); verifyNoOtherInteractionsAndReset(); - assertNotNull( actualReturn ); - assertTrue( actualReturn.isPresent() ); - assertSame( expectedReturn, actualReturn.get() ); + assertThat( actualReturn ).isNotNull() + .isPresent() + .get().isSameAs( expectedReturn ); TreeNestingContext level3Context = nestedContextCapture.getValue(); @@ -230,7 +225,7 @@ relativePrefix, definition, new TreeFilterPathTracker( definition ), @Test @TestForIssue(jiraKey = "HSEARCH-2552") - public void nestComposed_includePaths() { + void nestComposed_includePaths() { TreeNestingContext rootContext = TreeNestingContext.root(); Set includePaths = new HashSet<>(); @@ -315,7 +310,7 @@ public void nestComposed_includePaths() { @Test @TestForIssue(jiraKey = "HSEARCH-3136") - public void nestComposed_includePaths_tracking() { + void nestComposed_includePaths_tracking() { TreeNestingContext rootContext = TreeNestingContext.root(); Set includePaths = new HashSet<>(); @@ -564,7 +559,7 @@ public void nestComposed_includePaths_tracking() { */ @Test - public void nestComposed_excludePaths_tracking() { + void nestComposed_excludePaths_tracking() { TreeNestingContext rootContext = TreeNestingContext.root(); Set excludePaths = new HashSet<>(); @@ -777,7 +772,7 @@ public void nestComposed_excludePaths_tracking() { */ @Test - public void nestComposed_excludePaths_depth1_excludeLevel2() { + void nestComposed_excludePaths_depth1_excludeLevel2() { TreeNestingContext rootContext = TreeNestingContext.root(); Set excludePaths = new HashSet<>(); @@ -855,7 +850,7 @@ public void nestComposed_excludePaths_depth1_excludeLevel2() { */ @Test - public void nestComposed_excludePaths_sameFieldDifferentLevels() { + void nestComposed_excludePaths_sameFieldDifferentLevels() { TreeNestingContext rootContext = TreeNestingContext.root(); Set excludePaths = new HashSet<>(); @@ -903,7 +898,7 @@ public void nestComposed_excludePaths_sameFieldDifferentLevels() { @Test @TestForIssue(jiraKey = "HSEARCH-2194") - public void nestComposed_noFilterThenIncludePaths() { + void nestComposed_noFilterThenIncludePaths() { TreeNestingContext rootContext = TreeNestingContext.root(); // First level of composition: no filter @@ -923,7 +918,7 @@ null, asSet( "raisonSociale" ), null } @Test - public void nestComposed_depth0() { + void nestComposed_depth0() { TreeNestingContext rootContext = TreeNestingContext.root(); // Depth == 0 => only include paths if they are explicitly included. @@ -936,7 +931,7 @@ public void nestComposed_depth0() { } @Test - public void nestComposed_depth1() { + void nestComposed_depth1() { TreeNestingContext rootContext = TreeNestingContext.root(); // Depth == 1 => implicitly include all fields at the first level, @@ -963,7 +958,7 @@ public void nestComposed_depth1() { } @Test - public void nestComposed_depth3_overridden() { + void nestComposed_depth3_overridden() { TreeNestingContext rootContext = TreeNestingContext.root(); // Depth == 3 => allow three levels of nesting with filter composition, including level1, @@ -1032,7 +1027,7 @@ public void nestComposed_depth3_overridden() { } @Test - public void nestComposed_includePaths_depth1() { + void nestComposed_includePaths_depth1() { TreeNestingContext rootContext = TreeNestingContext.root(); Set includePaths = new HashSet<>(); @@ -1106,7 +1101,7 @@ public void nestComposed_includePaths_depth1() { @Test @TestForIssue(jiraKey = "HSEARCH-3136") - public void nestComposed_includePaths_depth1_tracking() { + void nestComposed_includePaths_depth1_tracking() { TreeNestingContext rootContext = TreeNestingContext.root(); Set includePaths = new HashSet<>(); @@ -1202,7 +1197,7 @@ public void nestComposed_includePaths_depth1_tracking() { } @Test - public void nestComposed_includePaths_nestComposed_includePaths() { + void nestComposed_includePaths_nestComposed_includePaths() { TreeNestingContext rootContext = TreeNestingContext.root(); Set includePaths = new HashSet<>(); @@ -1243,7 +1238,7 @@ public void nestComposed_includePaths_nestComposed_includePaths() { } @Test - public void nestComposed_includePaths_nestComposed_depth1AndIncludePaths() { + void nestComposed_includePaths_nestComposed_depth1AndIncludePaths() { TreeNestingContext rootContext = TreeNestingContext.root(); Set includePaths = new HashSet<>(); @@ -1277,7 +1272,7 @@ public void nestComposed_includePaths_nestComposed_depth1AndIncludePaths() { @Test @TestForIssue(jiraKey = "HSEARCH-3684") - public void nestComposed_includePaths_nestComposed_depth2AndIncludePaths() { + void nestComposed_includePaths_nestComposed_depth2AndIncludePaths() { TreeNestingContext rootContext = TreeNestingContext.root(); Set includePaths = new HashSet<>(); @@ -1325,7 +1320,7 @@ private void checkLeafIncluded(String expectedPrefixedName, TreeNestingContext c .thenReturn( expectedReturn ); Object actualReturn = context.nest( relativeFieldName, leafFactoryMock ); verifyNoOtherInteractionsAndReset(); - assertSame( expectedReturn, actualReturn ); + assertThat( expectedReturn ).isSameAs( actualReturn ); } private void checkLeafExcluded(String expectedPrefixedName, TreeNestingContext context, @@ -1335,7 +1330,7 @@ private void checkLeafExcluded(String expectedPrefixedName, TreeNestingContext c .thenReturn( expectedReturn ); Object actualReturn = context.nest( relativeFieldName, leafFactoryMock ); verifyNoOtherInteractionsAndReset(); - assertSame( expectedReturn, actualReturn ); + assertThat( expectedReturn ).isSameAs( actualReturn ); } private TreeNestingContext checkCompositeIncluded(String expectedPrefixedName, @@ -1350,7 +1345,7 @@ private TreeNestingContext checkCompositeIncluded(String expectedPrefixedName, .thenReturn( expectedReturn ); Object actualReturn = context.nest( relativeFieldName, compositeFactoryMock ); verifyNoOtherInteractionsAndReset(); - assertSame( expectedReturn, actualReturn ); + assertThat( expectedReturn ).isSameAs( actualReturn ); // Also check that dynamic leaves will be included checkDynamicIncluded( "", nestedContextCapture.getValue() ); @@ -1375,7 +1370,7 @@ private void checkCompositeExcluded(String expectedPrefixedName, TreeNestingCont .thenReturn( expectedReturn ); Object actualReturn = context.nest( relativeFieldName, compositeFactoryMock ); verifyNoOtherInteractionsAndReset(); - assertSame( expectedReturn, actualReturn ); + assertThat( expectedReturn ).isSameAs( actualReturn ); if ( recurse ) { // Also check that leaves will be excluded @@ -1390,7 +1385,7 @@ private void checkDynamicIncluded(String expectedPrefix, TreeNestingContext cont .thenReturn( expectedReturn ); Object actualReturn = context.nestUnfiltered( unfilteredFactoryMock ); verifyNoOtherInteractionsAndReset(); - assertSame( expectedReturn, actualReturn ); + assertThat( expectedReturn ).isSameAs( actualReturn ); } private void checkDynamicExcluded(String expectedPrefix, TreeNestingContext context) { @@ -1399,7 +1394,7 @@ private void checkDynamicExcluded(String expectedPrefix, TreeNestingContext cont .thenReturn( expectedReturn ); Object actualReturn = context.nestUnfiltered( unfilteredFactoryMock ); verifyNoOtherInteractionsAndReset(); - assertSame( expectedReturn, actualReturn ); + assertThat( expectedReturn ).isSameAs( actualReturn ); } private TreeNestingContext checkSimpleComposedFilterIncluded(String expectedObjectName, @@ -1426,13 +1421,15 @@ private TreeNestingContext checkSimpleComposedFilterIncluded(String expectedObje pathTracker, nestedContextBuilderMock, CYCLIC_RECURSION_EXCEPTION_FACTORY ); - assertNotNull( "Expected .nestComposed() to return a non-null result", actualReturn ); - assertTrue( "Expected the composed filter to be included in " + context, actualReturn.isPresent() ); + assertThat( actualReturn ).as( "Expected .nestComposed() to return a non-null result" ) + .isNotNull() + .as( "Expected the composed filter to be included in " + context ) + .isPresent(); InOrder inOrder = inOrder( nestedContextBuilderMock ); inOrder.verify( nestedContextBuilderMock ).appendObject( expectedObjectName ); inOrder.verify( nestedContextBuilderMock ).build( nestedContextCapture.capture() ); verifyNoOtherInteractionsAndReset(); - assertSame( expectedReturn, actualReturn.get() ); + assertThat( expectedReturn ).isSameAs( actualReturn.get() ); return nestedContextCapture.getValue(); } @@ -1451,8 +1448,10 @@ private void checkSimpleComposedFilterExcluded(TreeNestingContext context, Optional actualReturn = context.nestComposed( new StubMappingElement( definingTypeModel, relativePrefix ), relativePrefix, definition, pathTracker, nestedContextBuilderMock, CYCLIC_RECURSION_EXCEPTION_FACTORY ); verifyNoOtherInteractionsAndReset(); - assertNotNull( "Expected .nestComposed() to return a non-null result", actualReturn ); - assertFalse( "Expected the composed filter to be excluded from " + context, actualReturn.isPresent() ); + assertThat( actualReturn ).as( "Expected .nestComposed() to return a non-null result" ) + .isNotNull() + .as( "Expected the composed filter to be excluded from " + context ) + .isEmpty(); } private void checkFooBarIncluded(String expectedPrefix, TreeNestingContext context) { diff --git a/engine/src/test/java/org/hibernate/search/engine/reporting/impl/FailSafeFailureHandlerWrapperTest.java b/engine/src/test/java/org/hibernate/search/engine/reporting/impl/FailSafeFailureHandlerWrapperTest.java index 5f1eb394bbc..7640bdac9b9 100644 --- a/engine/src/test/java/org/hibernate/search/engine/reporting/impl/FailSafeFailureHandlerWrapperTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/reporting/impl/FailSafeFailureHandlerWrapperTest.java @@ -14,24 +14,24 @@ import org.hibernate.search.engine.reporting.EntityIndexingFailureContext; import org.hibernate.search.engine.reporting.FailureContext; import org.hibernate.search.engine.reporting.FailureHandler; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class FailSafeFailureHandlerWrapperTest { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class FailSafeFailureHandlerWrapperTest { - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Mock @@ -39,13 +39,13 @@ public class FailSafeFailureHandlerWrapperTest { private FailSafeFailureHandlerWrapper wrapper; - @Before - public void setup() { + @BeforeEach + void setup() { wrapper = new FailSafeFailureHandlerWrapper( failureHandlerMock ); } @Test - public void genericContext_runtimeException() { + void genericContext_runtimeException() { RuntimeException runtimeException = new SimulatedRuntimeException(); logged.expectEvent( @@ -58,7 +58,7 @@ Level.ERROR, sameInstance( runtimeException ), "failure handler threw an excepti } @Test - public void genericContext_error() { + void genericContext_error() { Error error = new SimulatedError(); logged.expectEvent( @@ -71,7 +71,7 @@ Level.ERROR, sameInstance( error ), "failure handler threw an exception" } @Test - public void entityIndexingContext_runtimeException() { + void entityIndexingContext_runtimeException() { RuntimeException runtimeException = new SimulatedRuntimeException(); logged.expectEvent( @@ -84,7 +84,7 @@ Level.ERROR, sameInstance( runtimeException ), "failure handler threw an excepti } @Test - public void entityIndexingContext_error() { + void entityIndexingContext_error() { Error error = new SimulatedError(); logged.expectEvent( diff --git a/engine/src/test/java/org/hibernate/search/engine/reporting/spi/RootFailureCollectorTest.java b/engine/src/test/java/org/hibernate/search/engine/reporting/spi/RootFailureCollectorTest.java index 80122e00d4e..9b7bdd336a9 100644 --- a/engine/src/test/java/org/hibernate/search/engine/reporting/spi/RootFailureCollectorTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/reporting/spi/RootFailureCollectorTest.java @@ -17,9 +17,9 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class RootFailureCollectorTest { +class RootFailureCollectorTest { /** * Triggers many more failures than the failure limit. @@ -27,7 +27,7 @@ public class RootFailureCollectorTest { * Only the first {@value RootFailureCollector#FAILURE_LIMIT} failures should be reported. */ @Test - public void failureLimit() { + void failureLimit() { RootFailureCollector rootFailureCollector = new RootFailureCollector( "RootName" ); for ( int i = 0; i < RootFailureCollector.FAILURE_LIMIT; i++ ) { ContextualFailureCollector failureCollector = rootFailureCollector.withContext( @@ -67,7 +67,7 @@ public void failureLimit() { * Do that concurrently from two different children, and you're likely to end up with a deadlock. */ @Test - public void failureLimit_concurrency() { + void failureLimit_concurrency() { RootFailureCollector rootFailureCollector = new RootFailureCollector( "RootName" ); List runnables = IntStream.range( 0, RootFailureCollector.FAILURE_LIMIT + 1000 ) .mapToObj( i -> (Runnable) () -> { diff --git a/engine/src/test/java/org/hibernate/search/engine/spatial/GeoPolygonTest.java b/engine/src/test/java/org/hibernate/search/engine/spatial/GeoPolygonTest.java index 4b191dde535..b35cc2c7dbd 100644 --- a/engine/src/test/java/org/hibernate/search/engine/spatial/GeoPolygonTest.java +++ b/engine/src/test/java/org/hibernate/search/engine/spatial/GeoPolygonTest.java @@ -6,28 +6,28 @@ */ package org.hibernate.search.engine.spatial; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertNotNull; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class GeoPolygonTest { +class GeoPolygonTest { @Test - public void validPolygon() { + void validPolygon() { GeoPolygon polygon = GeoPolygon.of( GeoPoint.of( 26, 23 ), GeoPoint.of( 26, 26 ), GeoPoint.of( 24, 26 ), GeoPoint.of( 24, 23 ), GeoPoint.of( 26, 23 ) ); - assertNotNull( polygon ); + assertThat( polygon ).isNotNull(); polygon = GeoPolygon.of( Arrays.asList( GeoPoint.of( 26, 23 ), GeoPoint.of( 26, 26 ), GeoPoint.of( 24, 26 ), GeoPoint.of( 24, 23 ), GeoPoint.of( 26, 23 ) ) ); - assertNotNull( polygon ); + assertThat( polygon ).isNotNull(); } @Test - public void invalidPolygon() { + void invalidPolygon() { assertThatThrownBy( () -> GeoPolygon.of( GeoPoint.of( 26, 23 ), diff --git a/integrationtest/backend/elasticsearch/pom.xml b/integrationtest/backend/elasticsearch/pom.xml index 69d479e99f1..c8cafe310a7 100644 --- a/integrationtest/backend/elasticsearch/pom.xml +++ b/integrationtest/backend/elasticsearch/pom.xml @@ -40,11 +40,6 @@ hibernate-search-util-internal-integrationtest-backend-elasticsearch test - - io.takari.junit - takari-cpsuite - test - com.github.tomakehurst wiremock diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/ElasticsearchExtensionIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/ElasticsearchExtensionIT.java index 8628f3ab7d1..d38ab5045c1 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/ElasticsearchExtensionIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/ElasticsearchExtensionIT.java @@ -53,16 +53,16 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.search.sort.SearchSort; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubLoadingOptionsStep; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -77,7 +77,7 @@ import org.json.JSONException; import org.skyscreamer.jsonassert.JSONCompareMode; -public class ElasticsearchExtensionIT { +class ElasticsearchExtensionIT { private static final String FIRST_ID = "1"; private static final String SECOND_ID = "2"; @@ -86,8 +86,8 @@ public class ElasticsearchExtensionIT { private static final String FIFTH_ID = "5"; private static final String EMPTY_ID = "empty"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); private final SimpleMappedIndex otherIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "other" ); @@ -96,8 +96,8 @@ public class ElasticsearchExtensionIT { private SearchIntegration integration; - @Before - public void setup() { + @BeforeEach + void setup() { this.integration = setupHelper.start().withIndexes( mainIndex, otherIndex ).setup().integration(); initData(); @@ -105,7 +105,7 @@ public void setup() { @Test @SuppressWarnings("unused") - public void queryContext() { + void queryContext() { StubMappingScope scope = mainIndex.createScope(); // Put intermediary contexts into variables to check they have the right type @@ -148,7 +148,7 @@ public void queryContext() { } @Test - public void query() { + void query() { StubMappingScope scope = mainIndex.createScope(); SearchQuery genericQuery = scope.query() @@ -171,7 +171,7 @@ public void query() { } @Test - public void query_gsonResponseBody() { + void query_gsonResponseBody() { StubMappingScope scope = mainIndex.createScope(); ElasticsearchSearchResult result = scope.query().extension( ElasticsearchExtension.get() ) @@ -184,7 +184,7 @@ public void query_gsonResponseBody() { } @Test - public void query_explain_singleIndex() { + void query_explain_singleIndex() { StubMappingScope scope = mainIndex.createScope(); ElasticsearchSearchQuery query = scope.query().extension( ElasticsearchExtension.get() ) @@ -206,7 +206,7 @@ public void query_explain_singleIndex() { @Test @TestForIssue(jiraKey = "HSEARCH-3783") - public void query_explain_projection() { + void query_explain_projection() { StubMappingScope scope = mainIndex.createScope(); ElasticsearchSearchQuery query = scope.query().extension( ElasticsearchExtension.get() ) @@ -228,7 +228,7 @@ public void query_explain_projection() { } @Test - public void query_explain_singleIndex_invalidId() { + void query_explain_singleIndex_invalidId() { StubMappingScope scope = mainIndex.createScope(); ElasticsearchSearchQuery query = scope.query().extension( ElasticsearchExtension.get() ) @@ -245,7 +245,7 @@ public void query_explain_singleIndex_invalidId() { } @Test - public void query_explain_multipleIndexes() { + void query_explain_multipleIndexes() { StubMappingScope scope = mainIndex.createScope( otherIndex ); ElasticsearchSearchQuery query = scope.query().extension( ElasticsearchExtension.get() ) @@ -266,7 +266,7 @@ public void query_explain_multipleIndexes() { } @Test - public void query_explain_multipleIndexes_missingTypeName() { + void query_explain_multipleIndexes_missingTypeName() { StubMappingScope scope = mainIndex.createScope( otherIndex ); ElasticsearchSearchQuery query = scope.query().extension( ElasticsearchExtension.get() ) @@ -282,7 +282,7 @@ public void query_explain_multipleIndexes_missingTypeName() { } @Test - public void query_explain_multipleIndexes_invalidIndexName() { + void query_explain_multipleIndexes_invalidIndexName() { StubMappingScope scope = mainIndex.createScope( otherIndex ); ElasticsearchSearchQuery query = scope.query().extension( ElasticsearchExtension.get() ) @@ -300,7 +300,7 @@ public void query_explain_multipleIndexes_invalidIndexName() { @Test @TestForIssue(jiraKey = "HSEARCH-3974") - public void scroll_onFetchable() { + void scroll_onFetchable() { // Check the scroll has the extended type and works correctly try ( ElasticsearchSearchScroll scroll = mainIndex.query() .extension( ElasticsearchExtension.get() ) // Call extension() on the DSL step @@ -321,7 +321,7 @@ public void scroll_onFetchable() { @Test @TestForIssue(jiraKey = "HSEARCH-3974") - public void scroll_onQuery() { + void scroll_onQuery() { // Check the scroll has the extended type and works correctly try ( ElasticsearchSearchScroll scroll = mainIndex.query() .where( f -> f.matchAll() ) @@ -342,7 +342,7 @@ public void scroll_onQuery() { } @Test - public void predicate_nativeField() { + void predicate_nativeField() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -355,7 +355,7 @@ public void predicate_nativeField() { } @Test - public void predicate_nativeField_withDslConverter_enabled() { + void predicate_nativeField_withDslConverter_enabled() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -368,7 +368,7 @@ public void predicate_nativeField_withDslConverter_enabled() { } @Test - public void predicate_nativeField_withDslConverter_disabled() { + void predicate_nativeField_withDslConverter_disabled() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -381,7 +381,7 @@ public void predicate_nativeField_withDslConverter_disabled() { } @Test - public void predicate_nativeField_fromJson_jsonObject() { + void predicate_nativeField_fromJson_jsonObject() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -413,7 +413,7 @@ public void predicate_nativeField_fromJson_jsonObject() { } @Test - public void predicate_nativeField_fromJson_jsonObject_separatePredicate() { + void predicate_nativeField_fromJson_jsonObject_separatePredicate() { StubMappingScope scope = mainIndex.createScope(); SearchPredicate predicate1 = scope.predicate().extension( ElasticsearchExtension.get() ) @@ -449,7 +449,7 @@ public void predicate_nativeField_fromJson_jsonObject_separatePredicate() { } @Test - public void predicate_nativeField_fromJson_string() { + void predicate_nativeField_fromJson_string() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -479,7 +479,7 @@ public void predicate_nativeField_fromJson_string() { } @Test - public void predicate_nativeField_fromJson_string_separatePredicate() { + void predicate_nativeField_fromJson_string_separatePredicate() { StubMappingScope scope = mainIndex.createScope(); SearchPredicate predicate1 = scope.predicate().extension( ElasticsearchExtension.get() ) @@ -514,7 +514,7 @@ public void predicate_nativeField_fromJson_string_separatePredicate() { } @Test - public void sort_nativeField() { + void sort_nativeField() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -547,7 +547,7 @@ public void sort_nativeField() { } @Test - public void sort_nativeField_jsonObject() { + void sort_nativeField_jsonObject() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -602,7 +602,7 @@ public void sort_nativeField_jsonObject() { } @Test - public void sort_nativeField_fromJson_jsonObject_separateSort() { + void sort_nativeField_fromJson_jsonObject_separateSort() { StubMappingScope scope = mainIndex.createScope(); SearchSort sort1Asc = scope.sort().extension( ElasticsearchExtension.get() ).fromJson( gson.fromJson( @@ -663,7 +663,7 @@ public void sort_nativeField_fromJson_jsonObject_separateSort() { } @Test - public void sort_nativeField_fromJson_string() { + void sort_nativeField_fromJson_string() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -708,7 +708,7 @@ public void sort_nativeField_fromJson_string() { } @Test - public void sort_nativeField_fromJson_string_separateSort() { + void sort_nativeField_fromJson_string_separateSort() { StubMappingScope scope = mainIndex.createScope(); SearchSort sort1Asc = scope.sort().extension( ElasticsearchExtension.get() ) @@ -759,7 +759,7 @@ public void sort_nativeField_fromJson_string_separateSort() { } @Test - public void sort_filter_fromJson() { + void sort_filter_fromJson() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -799,7 +799,7 @@ public void sort_filter_fromJson() { } @Test - public void projection_nativeField() { + void projection_nativeField() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -812,7 +812,7 @@ public void projection_nativeField() { @Test @SuppressWarnings("rawtypes") - public void projection_nativeField_withProjectionConverters_enabled() { + void projection_nativeField_withProjectionConverters_enabled() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -824,7 +824,7 @@ public void projection_nativeField_withProjectionConverters_enabled() { } @Test - public void projection_nativeField_withProjectionConverters_disabled() { + void projection_nativeField_withProjectionConverters_disabled() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -836,7 +836,7 @@ public void projection_nativeField_withProjectionConverters_disabled() { } @Test - public void projection_document() throws JSONException { + void projection_document() throws JSONException { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -868,7 +868,7 @@ public void projection_document() throws JSONException { * even if there is a field projection, which would usually trigger source filtering. */ @Test - public void projection_documentAndField() { + void projection_documentAndField() { StubMappingScope scope = mainIndex.createScope(); SearchQuery> query = scope.query() @@ -900,7 +900,7 @@ public void projection_documentAndField() { } @Test - public void projection_explanation() { + void projection_explanation() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -917,7 +917,7 @@ public void projection_explanation() { } @Test - public void projection_jsonHit() { + void projection_jsonHit() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -938,7 +938,7 @@ public void projection_jsonHit() { } @Test - public void aggregation_nativeField() { + void aggregation_nativeField() { StubMappingScope scope = mainIndex.createScope(); AggregationKey> documentCountPerValue = AggregationKey.of( "documentCountPerValue" ); @@ -957,7 +957,7 @@ public void aggregation_nativeField() { } @Test - public void aggregation_nativeField_fromJson_jsonObject() { + void aggregation_nativeField_fromJson_jsonObject() { StubMappingScope scope = mainIndex.createScope(); AggregationKey documentCountPerValue = AggregationKey.of( "documentCountPerValue" ); @@ -985,7 +985,7 @@ public void aggregation_nativeField_fromJson_jsonObject() { @Test - public void aggregation_nativeField_fromJson_string() { + void aggregation_nativeField_fromJson_string() { StubMappingScope scope = mainIndex.createScope(); AggregationKey documentCountPerValue = AggregationKey.of( "documentCountPerValue" ); @@ -1012,7 +1012,7 @@ public void aggregation_nativeField_fromJson_string() { @Test - public void aggregation_filter_fromLuceneQuery() { + void aggregation_filter_fromLuceneQuery() { StubMappingScope scope = mainIndex.createScope(); AggregationKey> aggregationKey = AggregationKey.of( "agg" ); @@ -1040,14 +1040,14 @@ public void aggregation_filter_fromLuceneQuery() { } @Test - public void backend_unwrap() { + void backend_unwrap() { Backend backend = integration.backend(); assertThat( backend.unwrap( ElasticsearchBackend.class ) ) .isNotNull(); } @Test - public void backend_unwrap_error_unknownType() { + void backend_unwrap_error_unknownType() { Backend backend = integration.backend(); assertThatThrownBy( () -> backend.unwrap( String.class ) ) @@ -1059,7 +1059,7 @@ public void backend_unwrap_error_unknownType() { } @Test - public void backend_getClient() throws Exception { + void backend_getClient() throws Exception { Backend backend = integration.backend(); ElasticsearchBackend elasticsearchBackend = backend.unwrap( ElasticsearchBackend.class ); RestClient restClient = elasticsearchBackend.client( RestClient.class ); @@ -1070,7 +1070,7 @@ public void backend_getClient() throws Exception { } @Test - public void backend_getClient_error_invalidClass() { + void backend_getClient_error_invalidClass() { Backend backend = integration.backend(); ElasticsearchBackend elasticsearchBackend = backend.unwrap( ElasticsearchBackend.class ); @@ -1085,14 +1085,14 @@ public void backend_getClient_error_invalidClass() { } @Test - public void mainIndex_unwrap() { + void mainIndex_unwrap() { IndexManager mainIndexFromIntegration = integration.indexManager( mainIndex.name() ); assertThat( mainIndexFromIntegration.unwrap( ElasticsearchIndexManager.class ) ) .isNotNull(); } @Test - public void mainIndex_unwrap_error_unknownType() { + void mainIndex_unwrap_error_unknownType() { IndexManager mainIndexFromIntegration = integration.indexManager( mainIndex.name() ); assertThatThrownBy( () -> mainIndexFromIntegration.unwrap( String.class ) ) @@ -1105,7 +1105,7 @@ public void mainIndex_unwrap_error_unknownType() { } @Test - public void jsonHitProjectionInsideNested() { + void jsonHitProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( ElasticsearchExtension.get() ).jsonHit() @@ -1121,7 +1121,7 @@ public void jsonHitProjectionInsideNested() { } @Test - public void sourceProjectionInsideNested() { + void sourceProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( ElasticsearchExtension.get() ).source() @@ -1137,7 +1137,7 @@ public void sourceProjectionInsideNested() { } @Test - public void explanationProjectionInsideNested() { + void explanationProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( ElasticsearchExtension.get() ).explanation() diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/analysis/ElasticsearchAnalysisConfigurerIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/analysis/ElasticsearchAnalysisConfigurerIT.java index e57e2d0bd89..e739a72088f 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/analysis/ElasticsearchAnalysisConfigurerIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/analysis/ElasticsearchAnalysisConfigurerIT.java @@ -15,31 +15,31 @@ import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.mapper.mapping.building.spi.IndexBindingContext; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchAnalysisConfigurerIT { +class ElasticsearchAnalysisConfigurerIT { private static final String ANALYSIS_CONFIGURER_ERROR_MESSAGE_PREFIX = "Unable to apply analysis configuration"; private static final String TYPE_NAME = "mainType"; private static final String INDEX_NAME = "mainIndex"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public final TestElasticsearchClient client = new TestElasticsearchClient(); + @RegisterExtension + public final TestElasticsearchClient client = TestElasticsearchClient.create(); @Test - public void error_invalidReference() { + void error_invalidReference() { assertThatThrownBy( () -> setup( "foobar" ) ) @@ -57,7 +57,7 @@ public void error_invalidReference() { } @Test - public void error_failingConfigurer() { + void error_failingConfigurer() { assertThatThrownBy( () -> setup( FailingConfigurer.class.getName() ) ) @@ -88,7 +88,7 @@ private static class SimulatedFailure extends RuntimeException { } @Test - public void error_tokenizer_namingConflict() { + void error_tokenizer_namingConflict() { assertThatThrownBy( () -> setup( TokenizerNamingConflictConfigurer.class.getName() ) ) @@ -113,7 +113,7 @@ public void configure(ElasticsearchAnalysisConfigurationContext context) { } @Test - public void error_tokenizer_missingType() { + void error_tokenizer_missingType() { assertThatThrownBy( () -> setup( TokenizerMissingTypeConfigurer.class.getName() ) ) @@ -137,7 +137,7 @@ public void configure(ElasticsearchAnalysisConfigurationContext context) { } @Test - public void error_charFilter_namingConflict() { + void error_charFilter_namingConflict() { assertThatThrownBy( () -> setup( CharFilterNamingConflictConfigurer.class.getName() ) ) @@ -162,7 +162,7 @@ public void configure(ElasticsearchAnalysisConfigurationContext context) { } @Test - public void error_charFilter_missingType() { + void error_charFilter_missingType() { assertThatThrownBy( () -> setup( CharFilterMissingTypeConfigurer.class.getName() ) ) @@ -186,7 +186,7 @@ public void configure(ElasticsearchAnalysisConfigurationContext context) { } @Test - public void error_tokenFilter_namingConflict() { + void error_tokenFilter_namingConflict() { assertThatThrownBy( () -> setup( TokenFilterNamingConflictConfigurer.class.getName() ) ) @@ -211,7 +211,7 @@ public void configure(ElasticsearchAnalysisConfigurationContext context) { } @Test - public void error_tokenFilter_missingType() { + void error_tokenFilter_missingType() { assertThatThrownBy( () -> setup( TokenFilterMissingTypeConfigurer.class.getName() ) ) @@ -235,7 +235,7 @@ public void configure(ElasticsearchAnalysisConfigurationContext context) { } @Test - public void error_parameter_namingConflict() { + void error_parameter_namingConflict() { assertThatThrownBy( () -> setup( ParameterNamingConflictConfigurer.class.getName() ) ) @@ -264,7 +264,7 @@ public void configure(ElasticsearchAnalysisConfigurationContext context) { @Test @TestForIssue(jiraKey = "HSEARCH-4594") - public void multipleConfigurers() { + void multipleConfigurers() { StubMappedIndex index = setup( MultipleConfigurers1.class.getName() + "," + MultipleConfigurers2.class.getName() ); assertJsonEquals( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/bootstrap/ElasticsearchBootstrapFailureIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/bootstrap/ElasticsearchBootstrapFailureIT.java index 4a6acda1486..a63d2c05135 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/bootstrap/ElasticsearchBootstrapFailureIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/bootstrap/ElasticsearchBootstrapFailureIT.java @@ -7,37 +7,39 @@ package org.hibernate.search.integrationtest.backend.elasticsearch.bootstrap; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchClientSpy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchBootstrapFailureIT { +class ElasticsearchBootstrapFailureIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public ElasticsearchClientSpy elasticsearchClientSpy = new ElasticsearchClientSpy(); + @RegisterExtension + public ElasticsearchClientSpy elasticsearchClientSpy = ElasticsearchClientSpy.create(); /** * Check the reported failure when we fail to connect to the Elasticsearch cluster. */ @Test @TestForIssue(jiraKey = "HSEARCH-3621") - public void cannotConnect() { - assumeTrue( "This test only works if the very first request to Elasticsearch" - + " is a version check, i.e. if version checks are supported", - ElasticsearchTckBackendFeatures.supportsVersionCheck() ); + void cannotConnect() { + assumeTrue( + ElasticsearchTckBackendFeatures.supportsVersionCheck(), + "This test only works if the very first request to Elasticsearch" + + " is a version check, i.e. if version checks are supported" + ); assertThatThrownBy( () -> setupHelper.start() diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/bootstrap/ElasticsearchBootstrapIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/bootstrap/ElasticsearchBootstrapIT.java index dd52db73883..4d6558ea4d0 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/bootstrap/ElasticsearchBootstrapIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/bootstrap/ElasticsearchBootstrapIT.java @@ -10,7 +10,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEqualsIgnoringUnknownFields; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.HashMap; import java.util.Map; @@ -27,28 +27,28 @@ import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchClientSpy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchRequestAssertionMode; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchBootstrapIT { +class ElasticsearchBootstrapIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public ElasticsearchClientSpy elasticsearchClientSpy = new ElasticsearchClientSpy(); + @RegisterExtension + public ElasticsearchClientSpy elasticsearchClientSpy = ElasticsearchClientSpy.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); @@ -58,7 +58,7 @@ public class ElasticsearchBootstrapIT { * and that the Elasticsearch client starts in the second phase of bootstrap in that case. */ @Test - public void explicitModelDialect() { + void explicitModelDialect() { SearchSetupHelper.PartialSetup partialSetup = setupHelper.start() .withBackendProperty( ElasticsearchBackendSettings.VERSION, ElasticsearchTestDialect.getActualVersion().toString() @@ -94,9 +94,11 @@ public void explicitModelDialect() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3841") - public void noVersionCheck_missingVersion() { - assumeTrue( "This test only makes sense if version checks are supported", - ElasticsearchTckBackendFeatures.supportsVersionCheck() ); + void noVersionCheck_missingVersion() { + assumeTrue( + ElasticsearchTckBackendFeatures.supportsVersionCheck(), + "This test only makes sense if version checks are supported" + ); assertThatThrownBy( () -> setupHelper.start() @@ -128,11 +130,13 @@ public void noVersionCheck_missingVersion() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3841") - public void noVersionCheck_incompleteVersion() { + void noVersionCheck_incompleteVersion() { ElasticsearchVersion actualVersion = ElasticsearchTestDialect.getActualVersion(); - assumeTrue( "This test only makes sense if the Elasticsearch version has both a major and minor number", - actualVersion.majorOptional().isPresent() && actualVersion.minor().isPresent() ); + assumeTrue( + actualVersion.majorOptional().isPresent() && actualVersion.minor().isPresent(), + "This test only makes sense if the Elasticsearch version has both a major and minor number" + ); String versionWithMajorOnly = actualVersion.distribution() + ":" + actualVersion.majorOptional().getAsInt(); assertThatThrownBy( @@ -171,7 +175,7 @@ public void noVersionCheck_incompleteVersion() { */ @Test @TestForIssue(jiraKey = { "HSEARCH-3841", "HSEARCH-4214" }) - public void noVersionCheck_completeVersion() { + void noVersionCheck_completeVersion() { ElasticsearchVersion actualVersion = ElasticsearchTestDialect.getActualVersion(); String configuredVersion; @@ -216,7 +220,7 @@ public void noVersionCheck_completeVersion() { */ @Test @TestForIssue(jiraKey = "HSEARCH-4214") - public void noVersionCheck_versionOverrideOnStart_incompatibleVersion() { + void noVersionCheck_versionOverrideOnStart_incompatibleVersion() { ElasticsearchVersion actualVersion = ElasticsearchTestDialect.getActualVersion(); String configuredVersionOnBackendCreation; @@ -278,11 +282,13 @@ public void noVersionCheck_versionOverrideOnStart_incompatibleVersion() { */ @Test @TestForIssue(jiraKey = "HSEARCH-4214") - public void noVersionCheck_versionOverrideOnStart_compatibleVersion() { + void noVersionCheck_versionOverrideOnStart_compatibleVersion() { ElasticsearchVersion actualVersion = ElasticsearchTestDialect.getActualVersion(); - assumeTrue( "This test only makes sense if the Elasticsearch version has both a major and minor number", - actualVersion.majorOptional().isPresent() && actualVersion.minor().isPresent() ); + assumeTrue( + actualVersion.majorOptional().isPresent() && actualVersion.minor().isPresent(), + "This test only makes sense if the Elasticsearch version has both a major and minor number" + ); String versionWithMajorOnly = actualVersion.distribution() + ":" + actualVersion.majorOptional().getAsInt(); String versionWithMajorAndMinorOnly = actualVersion.distribution() + ":" + actualVersion.majorOptional().getAsInt() + "." + actualVersion.minor().getAsInt(); @@ -321,7 +327,7 @@ public void noVersionCheck_versionOverrideOnStart_compatibleVersion() { */ @Test @TestForIssue(jiraKey = { "HSEARCH-4435" }) - public void noVersionCheck_customSettingsAndMapping() { + void noVersionCheck_customSettingsAndMapping() { ElasticsearchVersion actualVersion = ElasticsearchTestDialect.getActualVersion(); String configuredVersion; diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/client/ElasticsearchClientFactoryImplIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/client/ElasticsearchClientFactoryImplIT.java index 9ccb7e1acd6..def0c6e967d 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/client/ElasticsearchClientFactoryImplIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/client/ElasticsearchClientFactoryImplIT.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.fail; import static org.awaitility.Awaitility.await; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import static org.junit.Assume.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -69,18 +69,18 @@ import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; -import org.hibernate.search.util.impl.test.rule.Retry; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.RetryExtension; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; import com.github.tomakehurst.wiremock.extension.Parameters; import com.github.tomakehurst.wiremock.http.Fault; import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.junit.WireMockRule; +import com.github.tomakehurst.wiremock.junit5.WireMockExtension; import com.github.tomakehurst.wiremock.matching.MatchResult; import com.github.tomakehurst.wiremock.matching.RequestMatcherExtension; import com.google.gson.GsonBuilder; @@ -110,30 +110,33 @@ import org.apache.logging.log4j.Level; import org.assertj.core.api.InstanceOfAssertFactories; import org.elasticsearch.client.RestClient; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.DefaultElasticsearchClientFactoryTest") -public class ElasticsearchClientFactoryImplIT { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +class ElasticsearchClientFactoryImplIT { // Some tests in here are flaky, for some reason once in a while wiremock takes a very long time to answer // even though no delay was configured. // The exact reason is unknown though, so just try multiple times... - @Rule - public Retry retry; + @RegisterExtension private final ExpectedLog4jLog logged = ExpectedLog4jLog.create(); - private final WireMockRule wireMockRule1 = new WireMockRule( wireMockConfig().port( 0 ) - .httpsPort( 0 ) /* Automatic port selection */ ); + @RegisterExtension + private final WireMockExtension wireMockRule1 = WireMockExtension.newInstance() + .options( wireMockConfig().dynamicPort().dynamicHttpsPort() ) + .build(); - private final WireMockRule wireMockRule2 = - new WireMockRule( wireMockConfig().port( 0 ).httpsPort( 0 ) /* Automatic port selection */ ); + @RegisterExtension + private final WireMockExtension wireMockRule2 = WireMockExtension.newInstance() + .options( wireMockConfig().dynamicPort().dynamicHttpsPort() ) + .build(); + @RegisterExtension private final TestConfigurationProvider testConfigurationProvider = new TestConfigurationProvider(); private final ThreadPoolProviderImpl threadPoolProvider = new ThreadPoolProviderImpl( @@ -142,12 +145,8 @@ public class ElasticsearchClientFactoryImplIT { private final ScheduledExecutorService timeoutExecutorService = threadPoolProvider.newScheduledExecutor( 1, "Timeout - " ); - public ElasticsearchClientFactoryImplIT() { - this.retry = Retry.withOtherRules( logged, wireMockRule1, wireMockRule2, testConfigurationProvider ); - } - - @After - public void cleanup() { + @AfterEach + void cleanup() { timeoutExecutorService.shutdownNow(); threadPoolProvider.close(); @@ -157,9 +156,9 @@ public void cleanup() { wireMockRule2.resetAll(); } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2274") - public void simple_http() { + void simple_http() { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessage"; String responseBody = "{ \"foo\": \"bar\" }"; @@ -183,8 +182,8 @@ public void simple_http() { } } - @Test - public void simple_httpClientConfigurer() throws Exception { + @RetryExtension.TestWithRetry + void simple_httpClientConfigurer() throws Exception { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessage"; String responseBody = "{ \"foo\": \"bar\" }"; @@ -216,9 +215,9 @@ public void simple_httpClientConfigurer() throws Exception { verify( responseInterceptor, times( 1 ) ).process( any(), any() ); } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-4099") - public void uris_http() { + void uris_http() { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessage"; String responseBody = "{ \"foo\": \"bar\" }"; @@ -246,9 +245,9 @@ public void uris_http() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-4051") - public void pathPrefix_http() { + void pathPrefix_http() { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessage"; String responseBody = "{ \"foo\": \"bar\" }"; @@ -276,9 +275,9 @@ public void pathPrefix_http() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-4099") - public void pathPrefix_uris() { + void pathPrefix_uris() { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessage"; String responseBody = "{ \"foo\": \"bar\" }"; @@ -307,9 +306,9 @@ public void pathPrefix_uris() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2274") - public void simple_https() { + void simple_https() { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessage"; String responseBody = "{ \"foo\": \"bar\" }"; @@ -338,9 +337,9 @@ public void simple_https() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2274") - public void uris_https() { + void uris_https() { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessage"; String responseBody = "{ \"foo\": \"bar\" }"; @@ -368,8 +367,8 @@ public void uris_https() { } } - @Test - public void error() { + @RetryExtension.TestWithRetry + void error() { String payload = "{ \"foo\": \"bar\" }"; String responseBody = "{ \"error\": \"ErrorMessageExplainingTheError\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType" ) ) @@ -386,8 +385,8 @@ public void error() { } } - @Test - public void unparseable() { + @RetryExtension.TestWithRetry + void unparseable() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType" ) ) .withRequestBody( equalToJson( payload ) ) @@ -411,8 +410,8 @@ public void unparseable() { .isInstanceOf( JsonSyntaxException.class ); } - @Test - public void timeout_read() { + @RetryExtension.TestWithRetry + void timeout_read() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType" ) ) .withRequestBody( equalToJson( payload ) ) @@ -438,8 +437,8 @@ public void timeout_read() { .isInstanceOf( IOException.class ); } - @Test - public void timeout_request() { + @RetryExtension.TestWithRetry + void timeout_request() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType" ) ) @@ -473,9 +472,9 @@ public void timeout_request() { * we don't trigger timeouts just because requests spend a long time waiting; * timeouts are only related to how long the *server* takes to answer. */ - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2836") - public void cloggedClient_noTimeout_read() { + void cloggedClient_noTimeout_read() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/long" ) ) .willReturn( elasticsearchResponse() @@ -510,9 +509,9 @@ public void cloggedClient_noTimeout_read() { * Verify that when a request timeout is set, and when the client is clogged (many pending requests), * we do trigger timeouts just because requests spend a long time waiting. */ - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2836") - public void cloggedClient_timeout_request() { + void cloggedClient_timeout_request() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/long" ) ) .willReturn( elasticsearchResponse() @@ -549,9 +548,9 @@ public void cloggedClient_timeout_request() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2235") - public void multipleHosts() { + void multipleHosts() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType" ) ) .withRequestBody( equalToJson( payload ) ) @@ -575,8 +574,8 @@ public void multipleHosts() { } } - @Test - public void multipleURIs() { + @RetryExtension.TestWithRetry + void multipleURIs() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType" ) ) .withRequestBody( equalToJson( payload ) ) @@ -600,9 +599,9 @@ public void multipleURIs() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2469") - public void multipleHosts_failover_serverError() { + void multipleHosts_failover_serverError() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType" ) ) .withRequestBody( equalToJson( payload ) ) @@ -638,9 +637,9 @@ public void multipleHosts_failover_serverError() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2469") - public void multipleHosts_failover_timeout() { + void multipleHosts_failover_timeout() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType" ) ) .withRequestBody( equalToJson( payload ) ) @@ -687,9 +686,9 @@ public void multipleHosts_failover_timeout() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2469") - public void multipleHosts_failover_fault() { + void multipleHosts_failover_fault() { String payload = "{ \"foo\": \"bar\" }"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType" ) ) .withRequestBody( equalToJson( payload ) ) @@ -725,10 +724,10 @@ public void multipleHosts_failover_fault() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2449") - public void discovery_http() { - String nodesInfoResult = dummyNodeInfoResponse( wireMockRule1.port(), wireMockRule2.port() ); + void discovery_http() { + String nodesInfoResult = dummyNodeInfoResponse( wireMockRule1.getPort(), wireMockRule2.getPort() ); wireMockRule1.stubFor( get( urlPathMatching( "/_nodes.*" ) ) .andMatching( httpProtocol() ) @@ -779,10 +778,10 @@ public void discovery_http() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2736") - public void discovery_https() { - String nodesInfoResult = dummyNodeInfoResponse( wireMockRule1.httpsPort(), wireMockRule2.httpsPort() ); + void discovery_https() { + String nodesInfoResult = dummyNodeInfoResponse( wireMockRule1.getHttpsPort(), wireMockRule2.getHttpsPort() ); wireMockRule1.stubFor( get( urlPathMatching( "/_nodes.*" ) ) .andMatching( httpsProtocol() ) @@ -854,14 +853,14 @@ public String getName() { }; } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2453") - public void authentication() { + void authentication() { assumeFalse( + ElasticsearchTestHostConnectionConfiguration.get().isAws(), "This test only is only relevant if Elasticsearch request are *NOT* automatically" + " augmented with an \"Authentication:\" header." + - " \"Authentication:\" headers are added by the AWS integration in particular.", - ElasticsearchTestHostConnectionConfiguration.get().isAws() + " \"Authentication:\" headers are added by the AWS integration in particular." ); String username = "ironman"; String password = "j@rV1s"; @@ -884,9 +883,9 @@ public void authentication() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2453") - public void authentication_error() { + void authentication_error() { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessageUnauthorized"; wireMockRule1.stubFor( post( urlPathMatching( "/myIndex/myType/_search" ) ) @@ -903,9 +902,9 @@ public void authentication_error() { } } - @Test + @RetryExtension.TestWithRetry @TestForIssue(jiraKey = "HSEARCH-2453") - public void authentication_http_password() { + void authentication_http_password() { String username = "ironman"; String password = "j@rV1s"; @@ -921,8 +920,8 @@ public void authentication_http_password() { } } - @Test - public void uriAndProtocol() { + @RetryExtension.TestWithRetry + void uriAndProtocol() { Consumer> additionalProperties = properties -> { properties.accept( ElasticsearchBackendSettings.URIS, "http://is-not-called:12345" ); properties.accept( ElasticsearchBackendSettings.PROTOCOL, "http" ); @@ -939,8 +938,8 @@ public void uriAndProtocol() { ); } - @Test - public void uriAndHosts() { + @RetryExtension.TestWithRetry + void uriAndHosts() { Consumer> additionalProperties = properties -> { properties.accept( ElasticsearchBackendSettings.URIS, "http://is-not-called:12345" ); properties.accept( ElasticsearchBackendSettings.HOSTS, "not-called-either:234" ); @@ -957,8 +956,8 @@ public void uriAndHosts() { ); } - @Test - public void differentProtocolsOnUris() { + @RetryExtension.TestWithRetry + void differentProtocolsOnUris() { Consumer> additionalProperties = properties -> { properties.accept( ElasticsearchBackendSettings.URIS, "http://is-not-called:12345, https://neather-is:12345" ); }; @@ -972,8 +971,8 @@ public void differentProtocolsOnUris() { ); } - @Test - public void emptyListOfUris() { + @RetryExtension.TestWithRetry + void emptyListOfUris() { Consumer> additionalProperties = properties -> { properties.accept( ElasticsearchBackendSettings.URIS, Collections.emptyList() ); }; @@ -985,8 +984,8 @@ public void emptyListOfUris() { ); } - @Test - public void emptyListOfHosts() { + @RetryExtension.TestWithRetry + void emptyListOfHosts() { Consumer> additionalProperties = properties -> { properties.accept( ElasticsearchBackendSettings.HOSTS, Collections.emptyList() ); }; @@ -998,8 +997,8 @@ public void emptyListOfHosts() { ); } - @Test - public void clientInstance() throws IOException { + @RetryExtension.TestWithRetry + void clientInstance() throws IOException { try ( RestClient myRestClient = RestClient.builder( HttpHost.create( httpUrisFor( wireMockRule1 ) ) ).build() ) { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessage"; @@ -1030,8 +1029,8 @@ public void clientInstance() throws IOException { } } - @Test - public void maxKeepAliveNegativeValue() { + @RetryExtension.TestWithRetry + void maxKeepAliveNegativeValue() { assertThatThrownBy( () -> createClient( properties -> { properties.accept( ElasticsearchBackendSettings.MAX_KEEP_ALIVE, -1 ); @@ -1043,17 +1042,17 @@ public void maxKeepAliveNegativeValue() { ); } - @Test - public void maxKeepAliveConnectionIsNotClosed() throws InterruptedException { + @RetryExtension.TestWithRetry + void maxKeepAliveConnectionIsNotClosed() throws InterruptedException { maxKeepAliveConnection( 100000, 1 ); } - @Test - public void maxKeepAliveConnectionIsClosed() throws InterruptedException { + @RetryExtension.TestWithRetry + void maxKeepAliveConnectionIsClosed() throws InterruptedException { maxKeepAliveConnection( 10, 2 ); } - public void maxKeepAliveConnection(long time, int connections) throws InterruptedException { + void maxKeepAliveConnection(long time, int connections) throws InterruptedException { String payload = "{ \"foo\": \"bar\" }"; String statusMessage = "StatusMessage"; String responseBody = "{ \"foo\": \"bar\" }"; @@ -1200,27 +1199,27 @@ private ElasticsearchRequest buildRequest(ElasticsearchRequest.Builder builder, return builder.build(); } - private static String httpHostAndPortFor(WireMockRule... rules) { - return Arrays.stream( rules ) - .map( rule -> "localhost:" + rule.port() ) + private static String httpHostAndPortFor(WireMockExtension... extensions) { + return Arrays.stream( extensions ) + .map( extension -> "localhost:" + extension.getPort() ) .collect( Collectors.joining( "," ) ); } - private static String httpsHostAndPortFor(WireMockRule... rules) { - return Arrays.stream( rules ) - .map( rule -> "localhost:" + rule.httpsPort() ) + private static String httpsHostAndPortFor(WireMockExtension... extensions) { + return Arrays.stream( extensions ) + .map( extension -> "localhost:" + extension.getHttpsPort() ) .collect( Collectors.joining( "," ) ); } - private static String httpUrisFor(WireMockRule... rules) { - return Arrays.stream( rules ) - .map( rule -> "http://localhost:" + rule.port() ) + private static String httpUrisFor(WireMockExtension... extensions) { + return Arrays.stream( extensions ) + .map( extension -> "http://localhost:" + extension.getPort() ) .collect( Collectors.joining( "," ) ); } - private static String httpsUrisFor(WireMockRule... rules) { - return Arrays.stream( rules ) - .map( rule -> "https://localhost:" + rule.httpsPort() ) + private static String httpsUrisFor(WireMockExtension... extensions) { + return Arrays.stream( extensions ) + .map( extension -> "https://localhost:" + extension.getHttpsPort() ) .collect( Collectors.joining( "," ) ); } diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/client/ElasticsearchContentLengthIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/client/ElasticsearchContentLengthIT.java index 3842e8abdd6..f8270e2ec9a 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/client/ElasticsearchContentLengthIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/client/ElasticsearchContentLengthIT.java @@ -11,8 +11,8 @@ import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -48,12 +48,12 @@ import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.junit.WireMockRule; +import com.github.tomakehurst.wiremock.junit5.WireMockExtension; import com.github.tomakehurst.wiremock.matching.UrlPathPattern; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -68,7 +68,7 @@ */ @TestForIssue(jiraKey = "HSEARCH-2849") @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.client.ElasticsearchContentLengthIT") -public class ElasticsearchContentLengthIT { +class ElasticsearchContentLengthIT { private static final JsonObject BODY_PART = JsonParser.parseString( "{ \"foo\": \"bar\" }" ).getAsJsonObject(); @@ -90,11 +90,12 @@ public class ElasticsearchContentLengthIT { private static final int BUFFER_LIMIT = 1024; - @Rule - public WireMockRule wireMockRule = - new WireMockRule( wireMockConfig().port( 0 ).httpsPort( 0 ) /* Automatic port selection */ ); + @RegisterExtension + private final WireMockExtension wireMockRule = WireMockExtension.newInstance() + .options( wireMockConfig().dynamicPort().dynamicHttpsPort() ) + .build(); - @Rule + @RegisterExtension public TestConfigurationProvider testConfigurationProvider = new TestConfigurationProvider(); private final ThreadPoolProviderImpl threadPoolProvider = new ThreadPoolProviderImpl( @@ -104,8 +105,8 @@ public class ElasticsearchContentLengthIT { private ScheduledExecutorService timeoutExecutorService = threadPoolProvider.newScheduledExecutor( 1, "Timeout - " ); - @After - public void cleanup() { + @AfterEach + void cleanup() { timeoutExecutorService.shutdownNow(); threadPoolProvider.close(); @@ -115,7 +116,7 @@ public void cleanup() { } @Test - public void tinyPayload() throws Exception { + void tinyPayload() throws Exception { wireMockRule.stubFor( post( urlPathLike( "/myIndex/myType" ) ) .willReturn( elasticsearchResponse().withStatus( 200 ) ) ); @@ -130,7 +131,7 @@ public void tinyPayload() throws Exception { } @Test - public void payloadJustBelowBufferSize() throws Exception { + void payloadJustBelowBufferSize() throws Exception { wireMockRule.stubFor( post( urlPathLike( "/myIndex/myType" ) ) .willReturn( elasticsearchResponse().withStatus( 200 ) ) ); @@ -151,11 +152,11 @@ public void payloadJustBelowBufferSize() throws Exception { * we can "stream" it to the remote cluster, and avoid storing it entirely in memory. */ @Test - public void payloadJustAboveBufferSize_noRequestPostProcessing() throws Exception { + void payloadJustAboveBufferSize_noRequestPostProcessing() throws Exception { assumeFalse( + ElasticsearchTestHostConnectionConfiguration.get().isAws(), "This test only is only relevant if Elasticsearch request are *NOT* post-processed." + - " Elasticsearch requests are post-processed by the AWS integration in particular.", - ElasticsearchTestHostConnectionConfiguration.get().isAws() + " Elasticsearch requests are post-processed by the AWS integration in particular." ); wireMockRule.stubFor( post( urlPathLike( "/myIndex/myType" ) ) .willReturn( elasticsearchResponse().withStatus( 200 ) ) ); @@ -179,11 +180,11 @@ public void payloadJustAboveBufferSize_noRequestPostProcessing() throws Exceptio * we have to store it entirely in memory, so chunked transfer does not make sense. */ @Test - public void payloadJustAboveBufferSize_requestPostProcessing() throws Exception { + void payloadJustAboveBufferSize_requestPostProcessing() throws Exception { assumeTrue( + ElasticsearchTestHostConnectionConfiguration.get().isAws(), "This test only is only relevant if Elasticsearch request are post-processed." + - " Elasticsearch requests are post-processed by the AWS integration in particular.", - ElasticsearchTestHostConnectionConfiguration.get().isAws() + " Elasticsearch requests are post-processed by the AWS integration in particular." ); wireMockRule.stubFor( post( urlPathLike( "/myIndex/myType" ) ) .willReturn( elasticsearchResponse().withStatus( 200 ) ) ); @@ -243,8 +244,8 @@ private ElasticsearchRequest buildRequest(ElasticsearchRequest.Builder builder, return builder.build(); } - private static String httpUriFor(WireMockRule rule) { - return "http://localhost:" + rule.port(); + private static String httpUriFor(WireMockExtension extension) { + return "http://localhost:" + extension.getPort(); } private static UrlPathPattern urlPathLike(String path) { diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/gson/ElasticsearchGsonConcurrencyIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/gson/ElasticsearchGsonConcurrencyIT.java index 5d5bcca746d..0a4b4051040 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/gson/ElasticsearchGsonConcurrencyIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/gson/ElasticsearchGsonConcurrencyIT.java @@ -12,12 +12,12 @@ import org.hibernate.search.engine.backend.document.IndexObjectFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Reproducer for HSEARCH-3725, @@ -39,7 +39,7 @@ * will see a null adapter and throw an exception. */ @TestForIssue(jiraKey = "HSEARCH-3725") -public class ElasticsearchGsonConcurrencyIT { +class ElasticsearchGsonConcurrencyIT { /* * Please keep these constants reasonably low so that routine builds don't take forever: @@ -51,11 +51,11 @@ public class ElasticsearchGsonConcurrencyIT { // This must be at least 2, but you don't need more than the number of CPU cores. private static final int INDEX_COUNT_PER_ATTEMPT = 4; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); @Test - public void repeatedlyStartMultipleIndexesSerializingWithGsonInParallel() throws IOException { + void repeatedlyStartMultipleIndexesSerializingWithGsonInParallel() throws IOException { for ( int i = 0; i < REPRODUCER_ATTEMPTS; i++ ) { startMultipleIndexesSerializingWithGsonInParallel(); setupHelper.cleanUp(); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/index/lifecycle/ElasticsearchIndexLifecycleStrategyIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/index/lifecycle/ElasticsearchIndexLifecycleStrategyIT.java index 0cf19083492..3bf9232c130 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/index/lifecycle/ElasticsearchIndexLifecycleStrategyIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/index/lifecycle/ElasticsearchIndexLifecycleStrategyIT.java @@ -8,25 +8,25 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests that setting the obsolete index lifecycle strategy property fails. */ -public class ElasticsearchIndexLifecycleStrategyIT { +class ElasticsearchIndexLifecycleStrategyIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); @Test @TestForIssue(jiraKey = "HSEARCH-3540") - public void noCall() { + void noCall() { StubMappedIndex index = StubMappedIndex.withoutFields(); assertThatThrownBy( () -> setupHelper.start() diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/index/naming/ElasticsearchIndexNamingBaseIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/index/naming/ElasticsearchIndexNamingBaseIT.java index a09001c7b5c..3d66c427d4f 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/index/naming/ElasticsearchIndexNamingBaseIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/index/naming/ElasticsearchIndexNamingBaseIT.java @@ -10,33 +10,33 @@ import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; import org.hibernate.search.backend.elasticsearch.index.layout.IndexLayoutStrategy; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test the base functionality of type name mapping strategies. */ @TestForIssue(jiraKey = "HSEARCH-3791") -public class ElasticsearchIndexNamingBaseIT { +class ElasticsearchIndexNamingBaseIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public final TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public final TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index1 = StubMappedIndex.withoutFields().name( "index1" ); private final StubMappedIndex index2 = StubMappedIndex.withoutFields().name( "index2" ); @Test - public void nameConflict_aliasesOfSingleIndex() { + void nameConflict_aliasesOfSingleIndex() { assertThatThrownBy( () -> setup( hardcodedStrategy( "alias-conflicting", "alias-conflicting", "index2-write", "index2-read" @@ -52,7 +52,7 @@ public void nameConflict_aliasesOfSingleIndex() { } @Test - public void crossIndexNameConflict_writeAliasAndWriteAlias() { + void crossIndexNameConflict_writeAliasAndWriteAlias() { setupExpectingCrossIndexNameConflict( "alias-conflicting", "index1-read", // Index 1 aliases "alias-conflicting", "index2-read", // Index 2 aliases @@ -61,7 +61,7 @@ public void crossIndexNameConflict_writeAliasAndWriteAlias() { } @Test - public void crossIndexNameConflict_readAliasAndReadAlias() { + void crossIndexNameConflict_readAliasAndReadAlias() { setupExpectingCrossIndexNameConflict( "index1-write", "alias-conflicting", // Index 1 aliases "index2-write", "alias-conflicting", // Index 2 aliases @@ -70,7 +70,7 @@ public void crossIndexNameConflict_readAliasAndReadAlias() { } @Test - public void crossIndexNameConflict_writeAliasAndReadAlias() { + void crossIndexNameConflict_writeAliasAndReadAlias() { setupExpectingCrossIndexNameConflict( "alias-conflicting", "index1-write", // Index 1 aliases "index2-write", "alias-conflicting", // Index 2 aliases @@ -79,7 +79,7 @@ public void crossIndexNameConflict_writeAliasAndReadAlias() { } @Test - public void crossIndexNameConflict_hibernateSearchNameAndWriteAlias() { + void crossIndexNameConflict_hibernateSearchNameAndWriteAlias() { setupExpectingCrossIndexNameConflict( index2.name(), "index1-read", // Index 1 aliases "index2-write", "index2-read", // Index 2 aliases @@ -88,7 +88,7 @@ public void crossIndexNameConflict_hibernateSearchNameAndWriteAlias() { } @Test - public void crossIndexNameConflict_hibernateSearchNameAndReadAlias() { + void crossIndexNameConflict_hibernateSearchNameAndReadAlias() { setupExpectingCrossIndexNameConflict( "index1-write", index2.name(), // Index 1 aliases "index2-write", "index2-read", // Index 2 aliases diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchFieldAttributesIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchFieldAttributesIT.java index 9e678c23aa2..db77dde4f9f 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchFieldAttributesIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchFieldAttributesIT.java @@ -20,27 +20,27 @@ import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchClientSpy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchRequestAssertionMode; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.JsonObject; -public class ElasticsearchFieldAttributesIT { +class ElasticsearchFieldAttributesIT { private final ElasticsearchTestDialect dialect = ElasticsearchTestDialect.get(); - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public ElasticsearchClientSpy clientSpy = new ElasticsearchClientSpy(); + @RegisterExtension + public ElasticsearchClientSpy clientSpy = ElasticsearchClientSpy.create(); @Test - public void verifyNorms() { + void verifyNorms() { JsonObject properties = new JsonObject(); properties.add( "keyword", fieldWithNorms( "keyword", false ) ); properties.add( "text", fieldWithNorms( "text", true ) ); @@ -56,7 +56,7 @@ public void verifyNorms() { } @Test - public void verifyTermVector() { + void verifyTermVector() { JsonObject properties = new JsonObject(); properties.add( "no", fieldWithTermVector( "no" ) ); properties.add( "yes", fieldWithTermVector( "yes" ) ); @@ -74,7 +74,7 @@ public void verifyTermVector() { } @Test - public void verifyNative() { + void verifyNative() { JsonObject nativeField = new JsonObject(); nativeField.addProperty( "type", "half_float" ); nativeField.addProperty( "ignore_malformed", true ); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchFieldTypesIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchFieldTypesIT.java index f33b46db62e..d39f35ff183 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchFieldTypesIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchFieldTypesIT.java @@ -16,32 +16,32 @@ import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchClientSpy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchRequestAssertionMode; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.JsonObject; /** * Test the property types defined on Elasticsearch server */ -public class ElasticsearchFieldTypesIT { +class ElasticsearchFieldTypesIT { private final ElasticsearchTestDialect dialect = ElasticsearchTestDialect.get(); - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public final ElasticsearchClientSpy clientSpy = new ElasticsearchClientSpy(); + @RegisterExtension + public final ElasticsearchClientSpy clientSpy = ElasticsearchClientSpy.create(); private final StubMappedIndex index = StubMappedIndex.ofNonRetrievable( IndexBinding::new ); @Test - public void test() { + void test() { if ( ElasticsearchTckBackendFeatures.supportsVersionCheck() ) { clientSpy.expectNext( ElasticsearchRequest.get().build(), diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchTypeNameMappingBaseIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchTypeNameMappingBaseIT.java index 4f4269a9f4d..516b4f8428a 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchTypeNameMappingBaseIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchTypeNameMappingBaseIT.java @@ -13,30 +13,32 @@ import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.mappingWithoutAnyProperty; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; import org.hibernate.search.backend.elasticsearch.index.layout.impl.IndexNames; import org.hibernate.search.backend.elasticsearch.util.spi.URLEncodedString; import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.google.gson.JsonObject; /** * Test the base functionality of type name mapping strategies. */ -@RunWith(Parameterized.class) -public class ElasticsearchTypeNameMappingBaseIT { +class ElasticsearchTypeNameMappingBaseIT { private static final String ID_1 = "id_1"; private static final String ID_2 = "id_2"; @@ -46,38 +48,29 @@ private enum IrregularIndexNameSupport { NO } - @Parameterized.Parameters(name = "{0}") - public static Object[][] configurations() { - return new Object[][] { - { null, mappingWithDiscriminatorProperty( "_entity_type" ), IrregularIndexNameSupport.YES }, - { "index-name", mappingWithoutAnyProperty(), IrregularIndexNameSupport.NO }, - { "discriminator", mappingWithDiscriminatorProperty( "_entity_type" ), IrregularIndexNameSupport.YES } - }; + public static List params() { + return Arrays.asList( + Arguments.of( null, mappingWithDiscriminatorProperty( "_entity_type" ), IrregularIndexNameSupport.YES ), + Arguments.of( "index-name", mappingWithoutAnyProperty(), IrregularIndexNameSupport.NO ), + Arguments.of( "discriminator", mappingWithDiscriminatorProperty( "_entity_type" ), + IrregularIndexNameSupport.YES ) + ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index1 = StubMappedIndex.withoutFields().name( "index1" ); private final StubMappedIndex index2 = StubMappedIndex.withoutFields().name( "index2" ); - private final String strategyName; - private final JsonObject expectedMappingContent; - private final IrregularIndexNameSupport irregularIndexNameSupport; - - public ElasticsearchTypeNameMappingBaseIT(String strategyName, JsonObject expectedMappingContent, + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void singleIndexScope(String strategyName, JsonObject expectedMappingContent, IrregularIndexNameSupport irregularIndexNameSupport) { - this.strategyName = strategyName; - this.expectedMappingContent = expectedMappingContent; - this.irregularIndexNameSupport = irregularIndexNameSupport; - } - - @Test - public void singleIndexScope() { - setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_AND_DROP ); + setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_AND_DROP, strategyName ); assertThatQuery( index1.createScope().query().where( f -> f.matchAll() ).toQuery() ) @@ -87,9 +80,11 @@ public void singleIndexScope() { ); } - @Test - public void multiIndexScope() { - setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_AND_DROP ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndexScope(String strategyName, JsonObject expectedMappingContent, + IrregularIndexNameSupport irregularIndexNameSupport) { + setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_AND_DROP, strategyName ); assertThatQuery( index1.createScope( index2 ).query().where( f -> f.matchAll() ).toQuery() @@ -102,10 +97,13 @@ public void multiIndexScope() { ); } - @Test - public void irregularIndexName_correctNamingSchemeAndIncorrectUniqueKey_singleIndexScope() { - createIndexesWithCorrectNamingSchemeIncorrectUniqueKeyAndCorrectAliases(); - setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void irregularIndexName_correctNamingSchemeAndIncorrectUniqueKey_singleIndexScope(String strategyName, + JsonObject expectedMappingContent, + IrregularIndexNameSupport irregularIndexNameSupport) { + createIndexesWithCorrectNamingSchemeIncorrectUniqueKeyAndCorrectAliases( expectedMappingContent ); + setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, strategyName ); SearchQuery query = index1.createScope().query() .where( f -> f.matchAll() ) @@ -119,10 +117,13 @@ public void irregularIndexName_correctNamingSchemeAndIncorrectUniqueKey_singleIn ); } - @Test - public void irregularIndexName_correctNamingSchemeAndIncorrectUniqueKey_multiIndexScope() { - createIndexesWithCorrectNamingSchemeIncorrectUniqueKeyAndCorrectAliases(); - setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void irregularIndexName_correctNamingSchemeAndIncorrectUniqueKey_multiIndexScope(String strategyName, + JsonObject expectedMappingContent, + IrregularIndexNameSupport irregularIndexNameSupport) { + createIndexesWithCorrectNamingSchemeIncorrectUniqueKeyAndCorrectAliases( expectedMappingContent ); + setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, strategyName ); SearchQuery query = index1.createScope( index2 ).query() .where( f -> f.matchAll() ) @@ -143,10 +144,13 @@ public void irregularIndexName_correctNamingSchemeAndIncorrectUniqueKey_multiInd } } - @Test - public void irregularIndexName_incorrectNamingScheme_singleIndexScope() { - createIndexesWithIncorrectNamingSchemeAndCorrectAliases(); - setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void irregularIndexName_incorrectNamingScheme_singleIndexScope(String strategyName, + JsonObject expectedMappingContent, + IrregularIndexNameSupport irregularIndexNameSupport) { + createIndexesWithIncorrectNamingSchemeAndCorrectAliases( expectedMappingContent ); + setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, strategyName ); SearchQuery query = index1.createScope().query() .where( f -> f.matchAll() ) @@ -160,10 +164,12 @@ public void irregularIndexName_incorrectNamingScheme_singleIndexScope() { ); } - @Test - public void irregularIndexName_incorrectNamingScheme_multiIndexScope() { - createIndexesWithIncorrectNamingSchemeAndCorrectAliases(); - setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void irregularIndexName_incorrectNamingScheme_multiIndexScope(String strategyName, JsonObject expectedMappingContent, + IrregularIndexNameSupport irregularIndexNameSupport) { + createIndexesWithIncorrectNamingSchemeAndCorrectAliases( expectedMappingContent ); + setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, strategyName ); SearchQuery query = index1.createScope( index2 ).query() .where( f -> f.matchAll() ) @@ -184,7 +190,8 @@ public void irregularIndexName_incorrectNamingScheme_multiIndexScope() { } } - private void createIndexesWithCorrectNamingSchemeIncorrectUniqueKeyAndCorrectAliases() { + private void createIndexesWithCorrectNamingSchemeIncorrectUniqueKeyAndCorrectAliases( + JsonObject expectedMappingContent) { URLEncodedString index1PrimaryName = IndexNames.encodeName( index1.name() + "-000001-somesuffix-000001" ); URLEncodedString index1WriteAlias = defaultWriteAlias( index1.name() ); URLEncodedString index1ReadAlias = defaultReadAlias( index1.name() ); @@ -199,7 +206,7 @@ private void createIndexesWithCorrectNamingSchemeIncorrectUniqueKeyAndCorrectAli .type().putMapping( expectedMappingContent ); } - private void createIndexesWithIncorrectNamingSchemeAndCorrectAliases() { + private void createIndexesWithIncorrectNamingSchemeAndCorrectAliases(JsonObject expectedMappingContent) { URLEncodedString index1PrimaryName = IndexNames.encodeName( index1.name() + "-somesuffix" ); URLEncodedString index1WriteAlias = defaultWriteAlias( index1.name() ); URLEncodedString index1ReadAlias = defaultReadAlias( index1.name() ); @@ -214,7 +221,7 @@ private void createIndexesWithIncorrectNamingSchemeAndCorrectAliases() { .type().putMapping( expectedMappingContent ); } - private void setup(StubMappingSchemaManagementStrategy schemaManagementStrategy) { + private void setup(StubMappingSchemaManagementStrategy schemaManagementStrategy, String strategyName) { setupHelper.start() .withSchemaManagement( schemaManagementStrategy ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchTypeNameMappingSchemaIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchTypeNameMappingSchemaIT.java index f64c70b2a4d..6bc02c3a93a 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchTypeNameMappingSchemaIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/mapping/ElasticsearchTypeNameMappingSchemaIT.java @@ -12,6 +12,9 @@ import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.mappingWithDiscriminatorProperty; import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.mappingWithoutAnyProperty; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; @@ -21,49 +24,40 @@ import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchClientSpy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchRequestAssertionMode; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.google.gson.JsonObject; /** * Test the schema produced by type name mapping strategies. */ -@RunWith(Parameterized.class) -public class ElasticsearchTypeNameMappingSchemaIT { - - @Parameterized.Parameters(name = "{0}") - public static Object[][] configurations() { - return new Object[][] { - { null, mappingWithDiscriminatorProperty( "_entity_type" ) }, - { "index-name", mappingWithoutAnyProperty() }, - { "discriminator", mappingWithDiscriminatorProperty( "_entity_type" ) } - }; +class ElasticsearchTypeNameMappingSchemaIT { + + public static List params() { + return Arrays.asList( + Arguments.of( null, mappingWithDiscriminatorProperty( "_entity_type" ) ), + Arguments.of( "index-name", mappingWithoutAnyProperty() ), + Arguments.of( "discriminator", mappingWithDiscriminatorProperty( "_entity_type" ) ) + ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public ElasticsearchClientSpy clientSpy = new ElasticsearchClientSpy(); + @RegisterExtension + public ElasticsearchClientSpy clientSpy = ElasticsearchClientSpy.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final String strategyName; - private final JsonObject expectedMappingContent; - - public ElasticsearchTypeNameMappingSchemaIT(String strategyName, JsonObject expectedMappingContent) { - this.strategyName = strategyName; - this.expectedMappingContent = expectedMappingContent; - } - - @Test - public void schema() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void schema(String strategyName, JsonObject expectedMappingContent) { if ( ElasticsearchTckBackendFeatures.supportsVersionCheck() ) { clientSpy.expectNext( ElasticsearchRequest.get().build(), @@ -77,7 +71,7 @@ public void schema() { ElasticsearchRequestAssertionMode.EXTENSIBLE ); clientSpy.expectNext( - indexCreationRequest(), + indexCreationRequest( expectedMappingContent ), ElasticsearchRequestAssertionMode.STRICT ); @@ -100,15 +94,15 @@ public void schema() { clientSpy.verifyExpectationsMet(); } - private ElasticsearchRequest indexCreationRequest() { + private ElasticsearchRequest indexCreationRequest(JsonObject expectedMappingContent) { ElasticsearchRequest.Builder schemaRequestBuilder = ElasticsearchRequest.put() .pathComponent( defaultPrimaryName( index.name() ) ) - .body( indexCreationPayload() ); + .body( indexCreationPayload( expectedMappingContent ) ); return schemaRequestBuilder.build(); } - private JsonObject indexCreationPayload() { + private JsonObject indexCreationPayload(JsonObject expectedMappingContent) { JsonObject payload = new JsonObject(); payload.add( "aliases", defaultAliasDefinitions( index.name() ) ); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/metamodel/ElasticsearchIndexDescriptorIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/metamodel/ElasticsearchIndexDescriptorIT.java index 6e66e820835..f362aea0e2f 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/metamodel/ElasticsearchIndexDescriptorIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/metamodel/ElasticsearchIndexDescriptorIT.java @@ -16,30 +16,30 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.metamodel.IndexDescriptor; import org.hibernate.search.engine.backend.metamodel.IndexFieldDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchIndexDescriptorIT { +class ElasticsearchIndexDescriptorIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.NONE ) .setup(); } @Test - public void test() { + void test() { ElasticsearchIndexDescriptor indexDescriptor = index.toApi() .unwrap( ElasticsearchIndexManager.class ).descriptor(); @@ -49,7 +49,7 @@ public void test() { } @Test - public void implicitFields() { + void implicitFields() { IndexDescriptor indexDescriptor = index.toApi().descriptor(); Optional valueFieldDescriptorOptional = indexDescriptor.field( "string" ); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/custom/ElasticsearchCustomIndexMappingIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/custom/ElasticsearchCustomIndexMappingIT.java index 604df5a2302..bdd01b7463f 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/custom/ElasticsearchCustomIndexMappingIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/custom/ElasticsearchCustomIndexMappingIT.java @@ -11,25 +11,25 @@ import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchCustomIndexMappingIT { +class ElasticsearchCustomIndexMappingIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); // Valid cases are tested elsewhere, e.g. ElasticsearchIndexSchemaManagerCreationCustomMappingIT @Test - public void notExisting() { + void notExisting() { assertThatThrownBy( () -> setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_MAPPING_FILE, "custom-index-mapping/not-existing.json" @@ -43,7 +43,7 @@ public void notExisting() { @Test @TestForIssue(jiraKey = "HSEARCH-4438") - public void notParsable() { + void notParsable() { assertThatThrownBy( () -> setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_MAPPING_FILE, "custom-index-mapping/not-parsable.json" @@ -57,7 +57,7 @@ public void notParsable() { } @Test - public void unknownParameter() { + void unknownParameter() { assertThatThrownBy( () -> setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_MAPPING_FILE, "custom-index-mapping/unknown-parameter.json" diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/custom/ElasticsearchCustomIndexSettingsIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/custom/ElasticsearchCustomIndexSettingsIT.java index 4384295976a..6d1c5cc7783 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/custom/ElasticsearchCustomIndexSettingsIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/custom/ElasticsearchCustomIndexSettingsIT.java @@ -16,23 +16,23 @@ import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchCustomIndexSettingsIT { +class ElasticsearchCustomIndexSettingsIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); @Test - public void valid() { + void valid() { setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_SETTINGS_FILE, "custom-index-settings/valid.json" @@ -47,7 +47,7 @@ public void valid() { } @Test - public void notExisting() { + void notExisting() { assertThatThrownBy( () -> setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_SETTINGS_FILE, "custom-index-settings/not-existing.json" @@ -61,7 +61,7 @@ public void notExisting() { @Test @TestForIssue(jiraKey = "HSEARCH-4438") - public void notParsable() { + void notParsable() { assertThatThrownBy( () -> setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_SETTINGS_FILE, "custom-index-settings/not-parsable.json" @@ -75,7 +75,7 @@ public void notParsable() { } @Test - public void unknownSetting() { + void unknownSetting() { assertThatThrownBy( () -> setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_SETTINGS_FILE, "custom-index-settings/unknown-setting.json" diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationAliasesIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationAliasesIT.java index 275693ceaf8..da22be3827b 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationAliasesIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationAliasesIT.java @@ -14,7 +14,8 @@ import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.encodeName; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; @@ -22,51 +23,45 @@ import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.backend.elasticsearch.util.spi.URLEncodedString; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.StubSingleIndexLayoutStrategy; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to aliases when creating indexes, * for all index-creating schema management operations. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3791") -public class ElasticsearchIndexSchemaManagerCreationAliasesIT { +class ElasticsearchIndexSchemaManagerCreationAliasesIT { - @Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.creating(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.creating().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerCreationAliasesIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test - public void success_defaultLayoutStrategy() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_defaultLayoutStrategy(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( null ); + setupAndCreateIndex( null, operation ); assertJsonEquals( "{" @@ -77,12 +72,13 @@ public void success_defaultLayoutStrategy() { ); } - @Test - public void success_noAliasLayoutStrategy() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_noAliasLayoutStrategy(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.indexNoAlias( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( "no-alias" ); + setupAndCreateIndex( "no-alias", operation ); assertJsonEquals( "{" @@ -91,12 +87,13 @@ public void success_noAliasLayoutStrategy() { ); } - @Test - public void success_customLayoutStrategy() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_customLayoutStrategy(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( new StubSingleIndexLayoutStrategy( "custom-write", "custom-read" ) ); + setupAndCreateIndex( new StubSingleIndexLayoutStrategy( "custom-write", "custom-read" ), operation ); assertJsonEquals( "{" @@ -111,8 +108,9 @@ public void success_customLayoutStrategy() { * Test that migrating from 6.0.0.Beta4 or earlier will just create new (empty) indexes, * keeping the old ones in place. */ - @Test - public void migrationFrom6Beta4OrEarlier() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void migrationFrom6Beta4OrEarlier(ElasticsearchIndexSchemaManagerOperation operation) { // Index layout of 6.0.0.Beta4 and before: aliases are missing, // and the primary Elasticsearch index name is just the Hibernate Search index name. URLEncodedString oldIndexName = encodeName( index.name() ); @@ -120,7 +118,7 @@ public void migrationFrom6Beta4OrEarlier() { .deleteAndCreate() .type().putMapping( simpleMappingForInitialization( "" ) ); - setupAndCreateIndex( null ); + setupAndCreateIndex( null, operation ); // New indexes are created assertJsonEquals( @@ -137,7 +135,7 @@ public void migrationFrom6Beta4OrEarlier() { ); } - private void setupAndCreateIndex(Object layoutStrategy) { + private void setupAndCreateIndex(Object layoutStrategy, ElasticsearchIndexSchemaManagerOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationAnalyzerIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationAnalyzerIT.java index 1db18e75a78..566f26cf4da 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationAnalyzerIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationAnalyzerIT.java @@ -8,54 +8,49 @@ import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import java.util.EnumSet; +import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.ElasticsearchIndexSchemaManagerAnalyzerITAnalysisConfigurer; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to analyzers when creating indexes, * for all index-creating schema management operations. */ -@RunWith(Parameterized.class) @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.ElasticsearchAnalyzerDefinitionCreationIT") -public class ElasticsearchIndexSchemaManagerCreationAnalyzerIT { +class ElasticsearchIndexSchemaManagerCreationAnalyzerIT { - @Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.creating(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.creating().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex mainIndex = StubMappedIndex.withoutFields().name( "main" ); private final StubMappedIndex otherIndex = StubMappedIndex.withoutFields().name( "other" ); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerCreationAnalyzerIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test - public void success_simple() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_simple(ElasticsearchIndexSchemaManagerOperation operation) { elasticSearchClient.index( mainIndex.name() ) .ensureDoesNotExist(); @@ -118,8 +113,9 @@ public void success_simple() { ); } - @Test - public void success_multiIndex() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_multiIndex(ElasticsearchIndexSchemaManagerOperation operation) { elasticSearchClient.index( mainIndex.name() ) .ensureDoesNotExist(); elasticSearchClient.index( otherIndex.name() ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationCustomMappingIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationCustomMappingIT.java index 480c420da55..f74c6e06cf2 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationCustomMappingIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationCustomMappingIT.java @@ -8,54 +8,50 @@ import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.IndexObjectFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to index custom mapping when creating indexes, * for all index-creating schema management operations. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-4253") -public class ElasticsearchIndexSchemaManagerCreationCustomMappingIT { +class ElasticsearchIndexSchemaManagerCreationCustomMappingIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.creating(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.creating().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerCreationCustomMappingIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test - public void noOverlapping() { - setupAndCreateIndex( "no-overlapping.json" ); + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void noOverlapping(ElasticsearchIndexSchemaManagerOperation operation) { + setupAndCreateIndex( "no-overlapping.json", operation ); assertJsonEquals( " { " + " 'dynamic':'strict', " + @@ -122,9 +118,10 @@ public void noOverlapping() { elasticsearchClient.index( index.name() ).type().getMapping() ); } - @Test - public void complexConflicts() { - setupAndCreateIndex( "complex-conflicts.json" ); + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void complexConflicts(ElasticsearchIndexSchemaManagerOperation operation) { + setupAndCreateIndex( "complex-conflicts.json", operation ); assertJsonEquals( " { " + " 'dynamic':'strict', " + @@ -203,7 +200,7 @@ public void complexConflicts() { elasticsearchClient.index( index.name() ).type().getMapping() ); } - private void setupAndCreateIndex(String customMappingFile) { + private void setupAndCreateIndex(String customMappingFile, ElasticsearchIndexSchemaManagerOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withIndexProperty( index.name(), ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_MAPPING_FILE, diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationCustomSettingsIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationCustomSettingsIT.java index 5ad33eb8a65..dcecacd678b 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationCustomSettingsIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationCustomSettingsIT.java @@ -9,57 +9,53 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to index custom settings when creating indexes, * for all index-creating schema management operations. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3934") -public class ElasticsearchIndexSchemaManagerCreationCustomSettingsIT { +class ElasticsearchIndexSchemaManagerCreationCustomSettingsIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.creating(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.creating().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerCreationCustomSettingsIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test - public void success_mergeWithNoOverlapping() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_mergeWithNoOverlapping(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.index( index.name() ) .ensureDoesNotExist(); // merge the default analysis configurer with the custom settings, // there are no overlapping of their definitions - setupAndCreateIndex( null, "custom-index-settings/valid.json" ); + setupAndCreateIndex( null, "custom-index-settings/valid.json", operation ); assertJsonEquals( " { " + @@ -118,14 +114,15 @@ public void success_mergeWithNoOverlapping() { .isEqualTo( "\"3\"" ); } - @Test - public void success_mergeWithOverlapping() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_mergeWithOverlapping(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.index( index.name() ) .ensureDoesNotExist(); // merge the default analysis configurer with the custom settings, // there are some overlapping of their definitions - setupAndCreateIndex( null, "custom-index-settings/overlapping.json" ); + setupAndCreateIndex( null, "custom-index-settings/overlapping.json", operation ); assertJsonEquals( " { " + @@ -171,14 +168,15 @@ public void success_mergeWithOverlapping() { .isEqualTo( "\"3\"" ); } - @Test - public void success_onlyCustomSettings() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_onlyCustomSettings(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.index( index.name() ) .ensureDoesNotExist(); // use an empty analysis configurer, // so that we have only the custom settings definitions - setupAndCreateIndex( new EmptyElasticsearchAnalysisConfigurer(), "custom-index-settings/valid.json" ); + setupAndCreateIndex( new EmptyElasticsearchAnalysisConfigurer(), "custom-index-settings/valid.json", operation ); assertJsonEquals( " { " + @@ -209,14 +207,17 @@ public void success_onlyCustomSettings() { .isEqualTo( "\"3\"" ); } - @Test - public void maxResultWindow() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void maxResultWindow(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.index( index.name() ) .ensureDoesNotExist(); // use an empty analysis configurer, // so that we have only the custom settings definitions - setupAndCreateIndex( new EmptyElasticsearchAnalysisConfigurer(), "custom-index-settings/max-result-window.json" ); + setupAndCreateIndex( new EmptyElasticsearchAnalysisConfigurer(), "custom-index-settings/max-result-window.json", + operation + ); assertJsonEquals( "\"250\"", @@ -224,7 +225,8 @@ public void maxResultWindow() { ); } - private void setupAndCreateIndex(ElasticsearchAnalysisConfigurer analysisConfigurer, String customSettingsFile) { + private void setupAndCreateIndex(ElasticsearchAnalysisConfigurer analysisConfigurer, String customSettingsFile, + ElasticsearchIndexSchemaManagerOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( ElasticsearchIndexSettings.ANALYSIS_CONFIGURER, analysisConfigurer ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationMappingBaseIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationMappingBaseIT.java index efc80ec0769..f553678aa91 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationMappingBaseIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationMappingBaseIT.java @@ -8,51 +8,46 @@ import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.types.Norms; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to the mapping when creating indexes, * for all index-creating schema management operations. */ -@RunWith(Parameterized.class) @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.Elasticsearch5SchemaCreationIT") -public class ElasticsearchIndexSchemaManagerCreationMappingBaseIT { +class ElasticsearchIndexSchemaManagerCreationMappingBaseIT { - @Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.creating(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.creating().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerCreationMappingBaseIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test - public void dateField() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void dateField(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asLocalDate() ) .toReference() ); @@ -60,7 +55,7 @@ public void dateField() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index ); + setupAndCreateIndex( index, operation ); assertJsonEquals( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForExpectations( @@ -75,8 +70,9 @@ public void dateField() { ); } - @Test - public void booleanField() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void booleanField(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asBoolean() ) .toReference() ); @@ -84,7 +80,7 @@ public void booleanField() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index ); + setupAndCreateIndex( index, operation ); assertJsonEquals( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForExpectations( @@ -97,8 +93,9 @@ public void booleanField() { ); } - @Test - public void keywordField() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void keywordField(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString() ) .toReference() ); @@ -106,7 +103,7 @@ public void keywordField() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index ); + setupAndCreateIndex( index, operation ); assertJsonEquals( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForExpectations( @@ -119,8 +116,9 @@ public void keywordField() { ); } - @Test - public void textField() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void textField(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "standard" ) ) .toReference() @@ -129,7 +127,7 @@ public void textField() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index ); + setupAndCreateIndex( index, operation ); assertJsonEquals( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForExpectations( @@ -142,8 +140,9 @@ public void textField() { ); } - @Test - public void textField_noNorms() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void textField_noNorms(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "standard" ).norms( Norms.NO ) ) .toReference() @@ -152,7 +151,7 @@ public void textField_noNorms() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index ); + setupAndCreateIndex( index, operation ); assertJsonEquals( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForExpectations( @@ -166,7 +165,7 @@ public void textField_noNorms() { ); } - private void setupAndCreateIndex(StubMappedIndex index) { + private void setupAndCreateIndex(StubMappedIndex index, ElasticsearchIndexSchemaManagerOperation operation) { setupHelper.start() .withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationMappingFieldTemplatesIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationMappingFieldTemplatesIT.java index 73efa9ae91e..4555ef88c55 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationMappingFieldTemplatesIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationMappingFieldTemplatesIT.java @@ -10,51 +10,46 @@ import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.defaultMetadataMappingForExpectations; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import java.util.EnumSet; +import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to the mapping's field templates when creating indexes, * for all index-creating schema management operations. */ -@RunWith(Parameterized.class) -public class ElasticsearchIndexSchemaManagerCreationMappingFieldTemplatesIT { +class ElasticsearchIndexSchemaManagerCreationMappingFieldTemplatesIT { - @Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.creating(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.creating().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerCreationMappingFieldTemplatesIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test - public void rootFieldTemplates() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void rootFieldTemplates(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate1", ObjectStructure.NESTED ) .matchingPathGlob( "*_obj" ); @@ -65,7 +60,7 @@ public void rootFieldTemplates() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index ); + setupAndCreateIndex( index, operation ); assertJsonEquals( "{" @@ -97,8 +92,9 @@ public void rootFieldTemplates() { ); } - @Test - public void nonRootFieldTemplates() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void nonRootFieldTemplates(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { IndexSchemaObjectField objectField = root.objectField( "staticObject" ); objectField.toReference(); @@ -111,7 +107,7 @@ public void nonRootFieldTemplates() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index ); + setupAndCreateIndex( index, operation ); assertJsonEquals( "{" @@ -147,8 +143,9 @@ public void nonRootFieldTemplates() { ); } - @Test - public void rootFieldTemplatesWithFileOverride() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void rootFieldTemplatesWithFileOverride(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate1", ObjectStructure.NESTED ) .matchingPathGlob( "*_obj" ); @@ -159,7 +156,7 @@ public void rootFieldTemplatesWithFileOverride() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index, Optional.of( "no-overlapping.json" ) ); + setupAndCreateIndex( index, operation, Optional.of( "no-overlapping.json" ) ); assertJsonEquals( "{" + @@ -209,8 +206,9 @@ public void rootFieldTemplatesWithFileOverride() { ); } - @Test - public void rootFieldTemplatesInTheFileNoOverride() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void rootFieldTemplatesInTheFileNoOverride(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { // these templates should get ignored since a mapping file already contains some dynamic templates in it root.objectFieldTemplate( "myTemplate3", ObjectStructure.NESTED ) @@ -222,7 +220,7 @@ public void rootFieldTemplatesInTheFileNoOverride() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index, Optional.of( "no-overlapping-with-templates.json" ) ); + setupAndCreateIndex( index, operation, Optional.of( "no-overlapping-with-templates.json" ) ); assertJsonEquals( "{" + @@ -272,8 +270,9 @@ public void rootFieldTemplatesInTheFileNoOverride() { ); } - @Test - public void nonRootFieldTemplatesWithFileOverride() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void nonRootFieldTemplatesWithFileOverride(ElasticsearchIndexSchemaManagerOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { IndexSchemaObjectField objectField = root.objectField( "staticObject" ); objectField.toReference(); @@ -286,7 +285,7 @@ public void nonRootFieldTemplatesWithFileOverride() { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndex( index, Optional.of( "no-overlapping.json" ) ); + setupAndCreateIndex( index, operation, Optional.of( "no-overlapping.json" ) ); assertJsonEquals( "{" + @@ -340,11 +339,12 @@ public void nonRootFieldTemplatesWithFileOverride() { ); } - private void setupAndCreateIndex(StubMappedIndex index) { - setupAndCreateIndex( index, Optional.empty() ); + private void setupAndCreateIndex(StubMappedIndex index, ElasticsearchIndexSchemaManagerOperation operation) { + setupAndCreateIndex( index, operation, Optional.empty() ); } - private void setupAndCreateIndex(StubMappedIndex index, Optional mappingFile) { + private void setupAndCreateIndex(StubMappedIndex index, ElasticsearchIndexSchemaManagerOperation operation, + Optional mappingFile) { SearchSetupHelper.SetupContext setupContext = setupHelper.start() .withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationNormalizerIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationNormalizerIT.java index 40a5a11841a..0625d241309 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationNormalizerIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationNormalizerIT.java @@ -8,54 +8,49 @@ import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import java.util.EnumSet; +import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.ElasticsearchIndexSchemaManagerNormalizerITAnalysisConfigurer; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to normalizers when creating indexes, * for all index-creating schema management operations. */ -@RunWith(Parameterized.class) @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.ElasticsearchAnalyzerDefinitionCreationIT") -public class ElasticsearchIndexSchemaManagerCreationNormalizerIT { +class ElasticsearchIndexSchemaManagerCreationNormalizerIT { - @Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.creating(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.creating().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex mainIndex = StubMappedIndex.withoutFields().name( "main" ); private final StubMappedIndex otherIndex = StubMappedIndex.withoutFields().name( "other" ); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerCreationNormalizerIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test - public void success_simple() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_simple(ElasticsearchIndexSchemaManagerOperation operation) { elasticSearchClient.index( mainIndex.name() ) .ensureDoesNotExist(); @@ -93,8 +88,9 @@ public void success_simple() { elasticSearchClient.index( mainIndex.name() ).settings( "index.analysis" ).get() ); } - @Test - public void success_multiIndex() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_multiIndex(ElasticsearchIndexSchemaManagerOperation operation) { elasticSearchClient.index( mainIndex.name() ) .ensureDoesNotExist(); elasticSearchClient.index( otherIndex.name() ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationOrPreservationIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationOrPreservationIT.java index cb8ac85ed22..bc65ea40d16 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationOrPreservationIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerCreationOrPreservationIT.java @@ -11,56 +11,52 @@ import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEqualsIgnoringUnknownFields; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to preserving a pre-existing index, * for all schema management operations that create missing indexes but leave existing indexes as-is. */ -@RunWith(Parameterized.class) @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.ElasticsearchSchemaCreateStrategyIT") -public class ElasticsearchIndexSchemaManagerCreationOrPreservationIT { +class ElasticsearchIndexSchemaManagerCreationOrPreservationIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.creatingOrPreserving(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.creatingOrPreserving().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "field", f -> f.asString() ) .toReference() ); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerCreationOrPreservationIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-2789") - public void alreadyExists() throws Exception { + void alreadyExists(ElasticsearchIndexSchemaManagerOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate(); elasticSearchClient.index( index.name() ).type().putMapping( simpleMappingForInitialization( @@ -85,7 +81,7 @@ public void alreadyExists() throws Exception { elasticSearchClient.index( index.name() ).type().getMapping() ); - setupAndCreateIndexIfMissingOnly(); + setupAndCreateIndexIfMissingOnly( operation ); // The mapping should be unchanged assertJsonEquals( @@ -101,13 +97,14 @@ public void alreadyExists() throws Exception { ); } - @Test + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-2789") - public void doesNotExist() throws Exception { + void doesNotExist(ElasticsearchIndexSchemaManagerOperation operation) throws Exception { elasticSearchClient.index( index.name() ) .ensureDoesNotExist(); - setupAndCreateIndexIfMissingOnly(); + setupAndCreateIndexIfMissingOnly( operation ); // Just check that *something* changed // Other test classes check that the changes actually make sense @@ -117,7 +114,7 @@ public void doesNotExist() throws Exception { ); } - private void setupAndCreateIndexIfMissingOnly() { + private void setupAndCreateIndexIfMissingOnly(ElasticsearchIndexSchemaManagerOperation operation) { setupHelper.start() .withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDropAndCreateIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDropAndCreateIT.java index 7bc4c7f15ea..d62977a3d9c 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDropAndCreateIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDropAndCreateIT.java @@ -15,26 +15,26 @@ import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to dropping, then creating the index. */ -public class ElasticsearchIndexSchemaManagerDropAndCreateIT { +class ElasticsearchIndexSchemaManagerDropAndCreateIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "field", f -> f.asString() ) .toReference() @@ -42,7 +42,7 @@ public class ElasticsearchIndexSchemaManagerDropAndCreateIT { @Test @TestForIssue(jiraKey = "HSEARCH-3759") - public void alreadyExists() { + void alreadyExists() { elasticSearchClient.index( index.name() ).deleteAndCreate(); elasticSearchClient.index( index.name() ).type().putMapping( simpleMappingForInitialization( @@ -84,7 +84,7 @@ public void alreadyExists() { @Test @TestForIssue(jiraKey = "HSEARCH-3759") - public void doesNotExist() { + void doesNotExist() { elasticSearchClient.index( index.name() ).ensureDoesNotExist(); assertThat( elasticSearchClient.index( index.name() ).exists() ).isFalse(); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDropIfExistingIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDropIfExistingIT.java index 1fc22ab630e..d3ea45faf6e 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDropIfExistingIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDropIfExistingIT.java @@ -13,26 +13,26 @@ import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to dropping the index. */ -public class ElasticsearchIndexSchemaManagerDropIfExistingIT { +class ElasticsearchIndexSchemaManagerDropIfExistingIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "field", f -> f.asString() ) .toReference() @@ -40,7 +40,7 @@ public class ElasticsearchIndexSchemaManagerDropIfExistingIT { @Test @TestForIssue(jiraKey = "HSEARCH-3759") - public void alreadyExists() { + void alreadyExists() { elasticSearchClient.index( index.name() ).deleteAndCreate(); elasticSearchClient.index( index.name() ).type().putMapping( simpleMappingForInitialization( @@ -62,7 +62,7 @@ public void alreadyExists() { @Test @TestForIssue(jiraKey = "HSEARCH-3759") - public void doesNotExist() { + void doesNotExist() { elasticSearchClient.index( index.name() ).ensureDoesNotExist(); assertThat( elasticSearchClient.index( index.name() ).exists() ).isFalse(); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDynamicMappingIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDynamicMappingIT.java index 2764e5b8ecb..ec01900b6df 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDynamicMappingIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerDynamicMappingIT.java @@ -9,8 +9,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import java.util.EnumSet; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; @@ -18,19 +19,18 @@ import org.hibernate.search.backend.elasticsearch.index.DynamicMapping; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.google.gson.Gson; @@ -38,20 +38,20 @@ * Tests for the dynamic mapping attribute, * for all creating schema management operations. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3122") -public class ElasticsearchIndexSchemaManagerDynamicMappingIT { +class ElasticsearchIndexSchemaManagerDynamicMappingIT { - @Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.creating(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.creating().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "field", f -> f.asString() ).toReference(); @@ -62,48 +62,48 @@ public static EnumSet operations() { } ); private final Gson gson = new Gson(); - private final ElasticsearchIndexSchemaManagerOperation operation; - public ElasticsearchIndexSchemaManagerDynamicMappingIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test - public void dynamicMapping_default() { - setupAndInspectIndex( null ); + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void dynamicMapping_default(ElasticsearchIndexSchemaManagerOperation operation) { + setupAndInspectIndex( null, operation ); String mapping = elasticSearchClient.index( index.name() ).type().getMapping(); verifyDynamicMapping( mapping, DynamicMapping.STRICT ); } - @Test - public void dynamicMapping_strict() { - setupAndInspectIndex( DynamicMapping.STRICT.externalRepresentation() ); + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void dynamicMapping_strict(ElasticsearchIndexSchemaManagerOperation operation) { + setupAndInspectIndex( DynamicMapping.STRICT.externalRepresentation(), operation ); String mapping = elasticSearchClient.index( index.name() ).type().getMapping(); verifyDynamicMapping( mapping, DynamicMapping.STRICT ); } - @Test - public void dynamicMapping_false() { - setupAndInspectIndex( DynamicMapping.FALSE.externalRepresentation() ); + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void dynamicMapping_false(ElasticsearchIndexSchemaManagerOperation operation) { + setupAndInspectIndex( DynamicMapping.FALSE.externalRepresentation(), operation ); String mapping = elasticSearchClient.index( index.name() ).type().getMapping(); verifyDynamicMapping( mapping, DynamicMapping.FALSE ); } - @Test - public void dynamicMapping_true() { - setupAndInspectIndex( DynamicMapping.TRUE.externalRepresentation() ); + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void dynamicMapping_true(ElasticsearchIndexSchemaManagerOperation operation) { + setupAndInspectIndex( DynamicMapping.TRUE.externalRepresentation(), operation ); String mapping = elasticSearchClient.index( index.name() ).type().getMapping(); verifyDynamicMapping( mapping, DynamicMapping.TRUE ); } - @Test - public void dynamicMapping_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void dynamicMapping_invalid(ElasticsearchIndexSchemaManagerOperation operation) { assertThatThrownBy( - () -> setupAndInspectIndex( "invalid" ) + () -> setupAndInspectIndex( "invalid", operation ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( @@ -112,7 +112,7 @@ public void dynamicMapping_invalid() { .hasMessageContaining( "Valid values are: [true, false, strict]" ); } - private void setupAndInspectIndex(String dynamicMapping) { + private void setupAndInspectIndex(String dynamicMapping, ElasticsearchIndexSchemaManagerOperation operation) { SearchSetupHelper.SetupContext setupContext = setupHelper.start() .withBackendProperty( // Don't contribute any analysis definitions, validation of those is tested in another test class diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerExporterIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerExporterIT.java index b95c638f597..12c486a24f7 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerExporterIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerExporterIT.java @@ -20,25 +20,25 @@ import org.hibernate.search.engine.backend.schema.management.spi.IndexSchemaCollector; import org.hibernate.search.engine.common.schema.management.SchemaExport; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.ElasticsearchIndexSchemaManagerAnalyzerITAnalysisConfigurer; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; -public class ElasticsearchIndexSchemaManagerExporterIT { +class ElasticsearchIndexSchemaManagerExporterIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); - @Rule - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); + @TempDir + Path temporaryFolder; private final StubMappedIndex mainIndex = StubMappedIndex.withoutFields().name( "main" ); - @Before - public void setUp() { + @BeforeEach + void setUp() { setupHelper.start() .withBackendProperty( ElasticsearchIndexSettings.ANALYSIS_CONFIGURER, @@ -50,8 +50,8 @@ public void setUp() { } @Test - public void export() throws IOException { - Path directory = temporaryFolder.newFolder().toPath(); + void export() throws IOException { + Path directory = temporaryFolder; String testIndexName = "test"; mainIndex.schemaManager().exportExpectedSchema( new IndexSchemaCollector() { @Override diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerInspectionAliasesIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerInspectionAliasesIT.java index bbdf3c37c97..f1715e3f767 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerInspectionAliasesIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerInspectionAliasesIT.java @@ -12,54 +12,49 @@ import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.defaultWriteAlias; import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.writeAliasDefinition; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to aliases when inspecting existing indexes, * for all alias-inspecting schema management operations. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3791") -public class ElasticsearchIndexSchemaManagerInspectionAliasesIT { +class ElasticsearchIndexSchemaManagerInspectionAliasesIT { - @Parameters(name = "With operation {0}") - public static EnumSet strategies() { - return ElasticsearchIndexSchemaManagerOperation.aliasInspecting(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.aliasInspecting().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerInspectionAliasesIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test - public void writeAliasTargetsMultipleIndexes() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void writeAliasTargetsMultipleIndexes(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.index( index.name() ) .deleteAndCreate(); // The write alias for index 1 also targets a second index @@ -68,7 +63,7 @@ public void writeAliasTargetsMultipleIndexes() { .aliases().put( defaultWriteAlias( index.name() ).original ); assertThatThrownBy( - this::setupAndInspectIndex + () -> setupAndInspectIndex( operation ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid Elasticsearch index layout", @@ -79,8 +74,9 @@ public void writeAliasTargetsMultipleIndexes() { "These names must resolve to a single index" ); } - @Test - public void readAliasTargetsMultipleIndexes() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void readAliasTargetsMultipleIndexes(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.index( index.name() ) .deleteAndCreate(); // The read alias for index 1 also targets a second index @@ -89,7 +85,7 @@ public void readAliasTargetsMultipleIndexes() { .aliases().put( defaultReadAlias( index.name() ).original ); assertThatThrownBy( - this::setupAndInspectIndex + () -> setupAndInspectIndex( operation ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid Elasticsearch index layout", @@ -100,8 +96,9 @@ public void readAliasTargetsMultipleIndexes() { "These names must resolve to a single index" ); } - @Test - public void readAndWriteAliasTargetDifferentIndexes() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void readAndWriteAliasTargetDifferentIndexes(ElasticsearchIndexSchemaManagerOperation operation) { elasticsearchClient.index( index.name() ) .deleteAndCreate(); // The write alias for index 1 actually targets a different index @@ -111,7 +108,7 @@ public void readAndWriteAliasTargetDifferentIndexes() { .aliases().move( defaultWriteAlias( index.name() ).original, defaultPrimaryName( "otherIndex" ).original, writeAliasDefinition() ); - assertThatThrownBy( this::setupAndInspectIndex ) + assertThatThrownBy( () -> setupAndInspectIndex( operation ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid Elasticsearch index layout", "index names [" + defaultWriteAlias( index.name() ) + ", " + defaultReadAlias( index.name() ) @@ -121,7 +118,7 @@ public void readAndWriteAliasTargetDifferentIndexes() { "These names must resolve to a single index" ); } - private void setupAndInspectIndex() { + private void setupAndInspectIndex(ElasticsearchIndexSchemaManagerOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerStatusCheckIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerStatusCheckIT.java index 56750b7fac1..0a36f57767d 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerStatusCheckIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerStatusCheckIT.java @@ -8,99 +8,101 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.backend.elasticsearch.index.IndexStatus; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests for the index status checks, * for all status-checking schema management operations. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-2456") -public class ElasticsearchIndexSchemaManagerStatusCheckIT { +class ElasticsearchIndexSchemaManagerStatusCheckIT { - @Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerOperation.statusChecking(); + public static List params() { + return ElasticsearchIndexSchemaManagerOperation.statusChecking().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final ElasticsearchIndexSchemaManagerOperation operation; - - public ElasticsearchIndexSchemaManagerStatusCheckIT(ElasticsearchIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Before + @BeforeEach public void checkAssumptions() { assumeTrue( - "This test only makes sense if the backend supports index status checks", - ElasticsearchTckBackendFeatures.supportsIndexStatusCheck() + ElasticsearchTckBackendFeatures.supportsIndexStatusCheck(), + "This test only makes sense if the backend supports index status checks" ); } - @Test - public void indexMissing() throws Exception { - assumeFalse( "The operation " + operation + " creates an index automatically." - + " No point running this test.", - ElasticsearchIndexSchemaManagerOperation.creating().contains( operation ) ); + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void indexMissing(ElasticsearchIndexSchemaManagerOperation operation) throws Exception { + assumeFalse( ElasticsearchIndexSchemaManagerOperation.creating().contains( operation ), + "The operation " + operation + " creates an index automatically." + + " No point running this test." + ); elasticSearchClient.index( index.name() ).ensureDoesNotExist(); - assertThatThrownBy( () -> setupAndInspectIndex( "index-settings-for-tests/5-replicas.json" ) ) + assertThatThrownBy( () -> setupAndInspectIndex( "index-settings-for-tests/5-replicas.json", operation ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "HSEARCH400050" ); } - @Test - public void invalidIndexStatus_creatingIndex() throws Exception { - assumeTrue( "The operation " + operation + " doesn't create an index automatically." - + " No point running this test.", - ElasticsearchIndexSchemaManagerOperation.creating().contains( operation ) ); + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void invalidIndexStatus_creatingIndex(ElasticsearchIndexSchemaManagerOperation operation) throws Exception { + assumeTrue( + ElasticsearchIndexSchemaManagerOperation.creating().contains( operation ), + "The operation " + operation + " doesn't create an index automatically." + + " No point running this test." + ); elasticSearchClient.index( index.name() ).ensureDoesNotExist(); // Make sure automatically created indexes will never be green by requiring 5 replicas // (more than the amount of ES nodes) - assertThatThrownBy( () -> setupAndInspectIndex( "index-settings-for-tests/5-replicas.json" ) ) + assertThatThrownBy( () -> setupAndInspectIndex( "index-settings-for-tests/5-replicas.json", operation ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "HSEARCH400024", "100ms" ); } - @Test - public void invalidIndexStatus_usingPreexistingIndex() throws Exception { - assumeFalse( "The operation " + operation + " drops the existing index automatically." - + " No point running this test.", - ElasticsearchIndexSchemaManagerOperation.dropping().contains( operation ) ); + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void invalidIndexStatus_usingPreexistingIndex(ElasticsearchIndexSchemaManagerOperation operation) throws Exception { + assumeFalse( + ElasticsearchIndexSchemaManagerOperation.dropping().contains( operation ), + "The operation " + operation + " drops the existing index automatically." + + " No point running this test." + ); // Make sure automatically created indexes will never be green by requiring 5 replicas // (more than the amount of ES nodes) @@ -110,13 +112,13 @@ public void invalidIndexStatus_usingPreexistingIndex() throws Exception { simpleMappingForInitialization( "" ) ); - assertThatThrownBy( () -> setupAndInspectIndex( "index-settings-for-tests/5-replicas.json" ) ) + assertThatThrownBy( () -> setupAndInspectIndex( "index-settings-for-tests/5-replicas.json", operation ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "HSEARCH400024", "100ms" ); } - private void setupAndInspectIndex(String settingsPath) { + private void setupAndInspectIndex(String settingsPath, ElasticsearchIndexSchemaManagerOperation operation) { setupHelper.start() .withBackendProperty( // Don't contribute any analysis definitions, validation of those is tested in another test class diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateAliasesIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateAliasesIT.java index 0a82dfe4385..36192382f6a 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateAliasesIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateAliasesIT.java @@ -16,31 +16,31 @@ import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to aliases when updating indexes. */ @TestForIssue(jiraKey = "HSEARCH-3791") -public class ElasticsearchIndexSchemaManagerUpdateAliasesIT { +class ElasticsearchIndexSchemaManagerUpdateAliasesIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); @Test - public void nothingToDo_defaultLayoutStrategy() { + void nothingToDo_defaultLayoutStrategy() { elasticsearchClient.index( index.name() ) .deleteAndCreate() .type().putMapping( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization( "" ) ); @@ -65,7 +65,7 @@ public void nothingToDo_defaultLayoutStrategy() { } @Test - public void nothingToDo_noAliasLayoutStrategy() { + void nothingToDo_noAliasLayoutStrategy() { elasticsearchClient.indexNoAlias( index.name() ) .deleteAndCreate() .type().putMapping( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization( "" ) ); @@ -84,7 +84,7 @@ public void nothingToDo_noAliasLayoutStrategy() { } @Test - public void writeAlias_missing() { + void writeAlias_missing() { elasticsearchClient.index( defaultPrimaryName( index.name() ), null, defaultReadAlias( index.name() ) ) .deleteAndCreate() .type().putMapping( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization( "" ) ); @@ -109,7 +109,7 @@ public void writeAlias_missing() { } @Test - public void writeAlias_invalid_filter() { + void writeAlias_invalid_filter() { elasticsearchClient.index( index.name() ) .deleteAndCreate() .type().putMapping( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization( "" ) ); @@ -135,7 +135,7 @@ public void writeAlias_invalid_filter() { } @Test - public void writeAlias_invalid_isWriteIndex() { + void writeAlias_invalid_isWriteIndex() { elasticsearchClient.index( index.name() ) .deleteAndCreate() .type().putMapping( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization( "" ) ); @@ -162,7 +162,7 @@ public void writeAlias_invalid_isWriteIndex() { } @Test - public void readAlias_missing() { + void readAlias_missing() { elasticsearchClient.index( defaultPrimaryName( index.name() ), defaultWriteAlias( index.name() ), null ) .deleteAndCreate() .type().putMapping( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization( "" ) ); @@ -186,7 +186,7 @@ public void readAlias_missing() { } @Test - public void readAlias_invalid_filter() { + void readAlias_invalid_filter() { elasticsearchClient.index( index.name() ) .deleteAndCreate() .type().putMapping( ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization( "" ) ); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateAnalyzerIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateAnalyzerIT.java index 3b78b0e63be..57155f29c86 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateAnalyzerIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateAnalyzerIT.java @@ -7,46 +7,46 @@ package org.hibernate.search.integrationtest.backend.elasticsearch.schema.management; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.ElasticsearchIndexSchemaManagerAnalyzerITAnalysisConfigurer; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to analyzers when updating indexes. */ @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.ElasticsearchAnalyzerDefinitionMigrationIT") -public class ElasticsearchIndexSchemaManagerUpdateAnalyzerIT { +class ElasticsearchIndexSchemaManagerUpdateAnalyzerIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - @Before - public void checkAssumption() { + @BeforeEach + void checkAssumption() { assumeTrue( - "This test only is only relevant if we are allowed to open/close Elasticsearch indexes.", - ElasticsearchTckBackendFeatures.supportsIndexClosingAndOpening() + ElasticsearchTckBackendFeatures.supportsIndexClosingAndOpening(), + "This test only is only relevant if we are allowed to open/close Elasticsearch indexes." ); } @Test - public void nothingToDo() throws Exception { + void nothingToDo() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -143,7 +143,7 @@ public void nothingToDo() throws Exception { } @Test - public void analyzer_missing() throws Exception { + void analyzer_missing() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -228,7 +228,7 @@ public void analyzer_missing() throws Exception { } @Test - public void analyzer_componentDefinition_missing() throws Exception { + void analyzer_componentDefinition_missing() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -310,7 +310,7 @@ public void analyzer_componentDefinition_missing() throws Exception { } @Test - public void analyzer_componentReference_invalid() throws Exception { + void analyzer_componentReference_invalid() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -402,7 +402,7 @@ public void analyzer_componentReference_invalid() throws Exception { } @Test - public void analyzer_componentDefinition_invalid() throws Exception { + void analyzer_componentDefinition_invalid() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateCustomMappingIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateCustomMappingIT.java index d3a4bdbf253..97b6639a8e6 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateCustomMappingIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateCustomMappingIT.java @@ -8,47 +8,47 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to index custom mapping when updating indexes. */ @TestForIssue(jiraKey = "HSEARCH-4253") -public class ElasticsearchIndexSchemaManagerUpdateCustomMappingIT { +class ElasticsearchIndexSchemaManagerUpdateCustomMappingIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - @Before - public void checkAssumption() { + @BeforeEach + void checkAssumption() { assumeTrue( - "This test only is only relevant if we are allowed to open/close Elasticsearch indexes.", - ElasticsearchTckBackendFeatures.supportsIndexClosingAndOpening() + ElasticsearchTckBackendFeatures.supportsIndexClosingAndOpening(), + "This test only is only relevant if we are allowed to open/close Elasticsearch indexes." ); } @Test - public void noOverlapping() { + void noOverlapping() { elasticsearchClient.index( index.name() ).deleteAndCreate(); elasticsearchClient.index( index.name() ).type().putMapping( " { " + @@ -167,7 +167,7 @@ public void noOverlapping() { } @Test - public void illegalUpdate() { + void illegalUpdate() { elasticsearchClient.index( index.name() ).deleteAndCreate(); elasticsearchClient.index( index.name() ).type().putMapping( " { " + diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateCustomSettingsIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateCustomSettingsIT.java index e2a4bf17176..5094ee819d8 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateCustomSettingsIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateCustomSettingsIT.java @@ -9,49 +9,49 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to index custom settings when updating indexes. */ @TestForIssue(jiraKey = "HSEARCH-3934") -public class ElasticsearchIndexSchemaManagerUpdateCustomSettingsIT { +class ElasticsearchIndexSchemaManagerUpdateCustomSettingsIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - @Before - public void checkAssumption() { + @BeforeEach + void checkAssumption() { assumeTrue( - "This test only is only relevant if we are allowed to open/close Elasticsearch indexes.", - ElasticsearchTckBackendFeatures.supportsIndexClosingAndOpening() + ElasticsearchTckBackendFeatures.supportsIndexClosingAndOpening(), + "This test only is only relevant if we are allowed to open/close Elasticsearch indexes." ); } @Test - public void nothingToDo() { + void nothingToDo() { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", " { " + " 'number_of_shards': '3', " + @@ -110,7 +110,7 @@ public void nothingToDo() { } @Test - public void change_analysis() { + void change_analysis() { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", " { " + " 'number_of_shards': '3', " + @@ -169,7 +169,7 @@ public void change_analysis() { } @Test - public void change_numberOfShards() { + void change_numberOfShards() { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", " { " + " 'number_of_shards': '7', " + @@ -203,7 +203,7 @@ public void change_numberOfShards() { } @Test - public void change_maxResultWindow() { + void change_maxResultWindow() { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", "{ 'max_result_window': '20000' }" ); setupAndUpdateIndex( "max-result-window.json" ); @@ -215,7 +215,7 @@ public void change_maxResultWindow() { } @Test - public void set_maxResultWindow() { + void set_maxResultWindow() { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", "{ }" ); setupAndUpdateIndex( "max-result-window.json" ); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateMappingBaseIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateMappingBaseIT.java index 9bdc0760a5f..754d7c40c8a 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateMappingBaseIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateMappingBaseIT.java @@ -16,35 +16,35 @@ import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to the mapping when updating indexes. */ @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.Elasticsearch5SchemaMigrationIT") -public class ElasticsearchIndexSchemaManagerUpdateMappingBaseIT { +class ElasticsearchIndexSchemaManagerUpdateMappingBaseIT { private static final String UPDATE_FAILED_MESSAGE_ID = "HSEARCH400035"; private static final String MAPPING_CREATION_FAILED_MESSAGE_ID = "HSEARCH400020"; private static final String ELASTICSEARCH_REQUEST_FAILED_MESSAGE_ID = "HSEARCH400007"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); @Test - public void nothingToDo_1() { + void nothingToDo_1() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asLocalDate() ) .toReference() ); @@ -89,7 +89,7 @@ public void nothingToDo_1() { } @Test - public void nothingToDo_2() { + void nothingToDo_2() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asBoolean() ) .toReference() ); @@ -127,7 +127,7 @@ public void nothingToDo_2() { } @Test - public void nothingToDo_3() { + void nothingToDo_3() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "defaultAnalyzer", @@ -188,7 +188,7 @@ public void nothingToDo_3() { } @Test - public void mapping_missing() throws Exception { + void mapping_missing() throws Exception { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asBoolean() ) .toReference() ); @@ -209,7 +209,7 @@ public void mapping_missing() throws Exception { } @Test - public void rootMapping_attribute_missing() throws Exception { + void rootMapping_attribute_missing() throws Exception { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asBoolean() ) .toReference() ); @@ -251,7 +251,7 @@ public void rootMapping_attribute_missing() throws Exception { } @Test - public void property_missing() throws Exception { + void property_missing() throws Exception { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asLocalDate() ) .toReference() ); @@ -286,7 +286,7 @@ public void property_missing() throws Exception { } @Test - public void property_attribute_invalid() { + void property_attribute_invalid() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asLocalDate() ) .toReference() ); @@ -315,7 +315,7 @@ public void property_attribute_invalid() { } @Test - public void property_attribute_invalid_conflictingAnalyzer() { + void property_attribute_invalid_conflictingAnalyzer() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "analyzer", f -> f.asString().analyzer( "customAnalyzer" ) @@ -346,7 +346,7 @@ public void property_attribute_invalid_conflictingAnalyzer() { } @Test - public void property_attribute_invalid_conflictingNormalizer() { + void property_attribute_invalid_conflictingNormalizer() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "normalizer", f -> f.asString().normalizer( "customNormalizer" ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateMappingFieldTemplateIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateMappingFieldTemplateIT.java index 259a26ca03f..26dda28ef02 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateMappingFieldTemplateIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateMappingFieldTemplateIT.java @@ -16,28 +16,28 @@ import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to the mapping when updating indexes and field templates are defined. */ -public class ElasticsearchIndexSchemaManagerUpdateMappingFieldTemplateIT { +class ElasticsearchIndexSchemaManagerUpdateMappingFieldTemplateIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); @Test - public void nothingToDo() { + void nothingToDo() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ) .matchingPathGlob( "*_t1" ); @@ -108,7 +108,7 @@ public void nothingToDo() { } @Test - public void missing() { + void missing() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ); root.fieldTemplate( "myTemplate2", f -> f.asString().analyzer( "default" ) ); @@ -162,7 +162,7 @@ public void missing() { } @Test - public void extra() { + void extra() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ); root.fieldTemplate( "myTemplate2", f -> f.asString().analyzer( "default" ) ); @@ -224,7 +224,7 @@ public void extra() { } @Test - public void wrongOrder() { + void wrongOrder() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ); root.fieldTemplate( "myTemplate2", f -> f.asString().analyzer( "default" ) ); @@ -282,7 +282,7 @@ public void wrongOrder() { } @Test - public void duplicate() { + void duplicate() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ); } ); @@ -326,7 +326,7 @@ public void duplicate() { } @Test - public void attribute_pathMatch_missing() { + void attribute_pathMatch_missing() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate", ObjectStructure.NESTED ) .matchingPathGlob( "*_suffix" ); @@ -368,7 +368,7 @@ public void attribute_pathMatch_missing() { } @Test - public void attribute_pathMatch_invalid() { + void attribute_pathMatch_invalid() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate", ObjectStructure.NESTED ) .matchingPathGlob( "*_suffix" ); @@ -411,7 +411,7 @@ public void attribute_pathMatch_invalid() { } @Test - public void attribute_pathMatch_extra() { + void attribute_pathMatch_extra() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate", f -> f.asString() ); } ); @@ -451,7 +451,7 @@ public void attribute_pathMatch_extra() { } @Test - public void attribute_matchMappingType_missing() { + void attribute_matchMappingType_missing() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate", ObjectStructure.NESTED ); } ); @@ -492,7 +492,7 @@ public void attribute_matchMappingType_missing() { } @Test - public void attribute_matchMappingType_invalid() { + void attribute_matchMappingType_invalid() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate", ObjectStructure.NESTED ); } ); @@ -534,7 +534,7 @@ public void attribute_matchMappingType_invalid() { } @Test - public void attribute_matchMappingType_extra() { + void attribute_matchMappingType_extra() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate", f -> f.asString() ); } ); @@ -575,7 +575,7 @@ public void attribute_matchMappingType_extra() { } @Test - public void attribute_extra() { + void attribute_extra() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate", f -> f.asString() ); } ); @@ -616,7 +616,7 @@ public void attribute_extra() { } @Test - public void mapping_invalid() { + void mapping_invalid() { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate", f -> f.asString() ); } ); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateNormalizerIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateNormalizerIT.java index e20282a89f3..41b203307f6 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateNormalizerIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerUpdateNormalizerIT.java @@ -7,46 +7,46 @@ package org.hibernate.search.integrationtest.backend.elasticsearch.schema.management; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.ElasticsearchIndexSchemaManagerNormalizerITAnalysisConfigurer; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchTckBackendFeatures; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to normalizers when updating indexes. */ @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.ElasticsearchNormalizerDefinitionMigrationIT") -public class ElasticsearchIndexSchemaManagerUpdateNormalizerIT { +class ElasticsearchIndexSchemaManagerUpdateNormalizerIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - @Before - public void checkAssumption() { + @BeforeEach + void checkAssumption() { assumeTrue( - "This test only is only relevant if we are allowed to open/close Elasticsearch indexes.", - ElasticsearchTckBackendFeatures.supportsIndexClosingAndOpening() + ElasticsearchTckBackendFeatures.supportsIndexClosingAndOpening(), + "This test only is only relevant if we are allowed to open/close Elasticsearch indexes." ); } @Test - public void nothingToDo() throws Exception { + void nothingToDo() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -99,7 +99,7 @@ public void nothingToDo() throws Exception { } @Test - public void normalizer_missing() throws Exception { + void normalizer_missing() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -147,7 +147,7 @@ public void normalizer_missing() throws Exception { } @Test - public void normalizer_componentDefinition_missing() throws Exception { + void normalizer_componentDefinition_missing() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -194,7 +194,7 @@ public void normalizer_componentDefinition_missing() throws Exception { } @Test - public void normalizer_componentReference_invalid() throws Exception { + void normalizer_componentReference_invalid() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -256,7 +256,7 @@ public void normalizer_componentReference_invalid() throws Exception { } @Test - public void normalizer_componentDefinition_invalid() throws Exception { + void normalizer_componentDefinition_invalid() throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationAliasesIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationAliasesIT.java index 66b62615d6d..31bf0e3fa84 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationAliasesIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationAliasesIT.java @@ -14,88 +14,85 @@ import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.defaultReadAlias; import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.defaultWriteAlias; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to aliases when validating indexes, * for all index-validating schema management operations. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3791") -public class ElasticsearchIndexSchemaManagerValidationAliasesIT { +class ElasticsearchIndexSchemaManagerValidationAliasesIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerValidationOperation.all(); + public static List params() { + return ElasticsearchIndexSchemaManagerValidationOperation.all().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final ElasticsearchIndexSchemaManagerValidationOperation operation; - - public ElasticsearchIndexSchemaManagerValidationAliasesIT( - ElasticsearchIndexSchemaManagerValidationOperation operation) { - this.operation = operation; - } - - @Test - public void success_defaultLayoutStrategy() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_defaultLayoutStrategy(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ) .deleteAndCreate() .type().putMapping( simpleMappingForInitialization( "" ) ); elasticsearchClient.index( index.name() ).aliases() .put( "somePreExistingAlias" ); - setupAndValidate(); + setupAndValidate( operation ); // If we get here, it means validation passed (no exception was thrown) } - @Test - public void success_noAliasLayoutStrategy() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_noAliasLayoutStrategy(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.indexNoAlias( index.name() ) .deleteAndCreate() .type().putMapping( simpleMappingForInitialization( "" ) ); elasticsearchClient.indexNoAlias( index.name() ).aliases() .put( "somePreExistingAlias" ); - setupAndValidate( "no-alias" ); + setupAndValidate( "no-alias", operation ); // If we get here, it means validation passed (no exception was thrown) } - @Test - public void writeAlias_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void writeAlias_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( defaultPrimaryName( index.name() ), null, defaultReadAlias( index.name() ) ) .deleteAndCreate() .type().putMapping( simpleMappingForInitialization( "" ) ); elasticsearchClient.index( index.name() ).aliases() .put( "somePreExistingAlias" ); - assertThatThrownBy( this::setupAndValidate ) + assertThatThrownBy( () -> setupAndValidate( operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() @@ -104,8 +101,9 @@ public void writeAlias_missing() { ); } - @Test - public void writeAlias_invalid_filter() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void writeAlias_invalid_filter(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ) .deleteAndCreate() .type().putMapping( simpleMappingForInitialization( "" ) ); @@ -117,7 +115,7 @@ public void writeAlias_invalid_filter() { simpleAliasDefinition( true, "'filter': {'term': {'user_id': 12}}" ) ); - assertThatThrownBy( this::setupAndValidate ) + assertThatThrownBy( () -> setupAndValidate( operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() @@ -127,8 +125,9 @@ public void writeAlias_invalid_filter() { ); } - @Test - public void writeAlias_invalid_isWriteIndex() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void writeAlias_invalid_isWriteIndex(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ) .deleteAndCreate() .type().putMapping( simpleMappingForInitialization( "" ) ); @@ -137,7 +136,7 @@ public void writeAlias_invalid_isWriteIndex() { elasticsearchClient.index( index.name() ).aliases() .put( defaultWriteAlias( index.name() ).original, simpleAliasDefinition( false, "" ) ); - assertThatThrownBy( this::setupAndValidate ) + assertThatThrownBy( () -> setupAndValidate( operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() @@ -147,15 +146,16 @@ public void writeAlias_invalid_isWriteIndex() { ); } - @Test - public void readAlias_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void readAlias_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( defaultPrimaryName( index.name() ), defaultWriteAlias( index.name() ), null ) .deleteAndCreate() .type().putMapping( simpleMappingForInitialization( "" ) ); elasticsearchClient.index( index.name() ).aliases() .put( "somePreExistingAlias" ); - assertThatThrownBy( this::setupAndValidate ) + assertThatThrownBy( () -> setupAndValidate( operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() @@ -164,8 +164,9 @@ public void readAlias_missing() { ); } - @Test - public void readAlias_invalid_filter() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void readAlias_invalid_filter(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ) .deleteAndCreate() .type().putMapping( simpleMappingForInitialization( "" ) ); @@ -174,7 +175,7 @@ public void readAlias_invalid_filter() { elasticsearchClient.index( index.name() ).aliases() .put( defaultReadAlias( index.name() ).original, "{'filter': {'term': {'user_id': 12}}}" ); - assertThatThrownBy( this::setupAndValidate ) + assertThatThrownBy( () -> setupAndValidate( operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() @@ -184,11 +185,11 @@ public void readAlias_invalid_filter() { ); } - private void setupAndValidate() { - setupAndValidate( null ); + private void setupAndValidate(ElasticsearchIndexSchemaManagerValidationOperation operation) { + setupAndValidate( null, operation ); } - private void setupAndValidate(Object layoutStrategy) { + private void setupAndValidate(Object layoutStrategy, ElasticsearchIndexSchemaManagerValidationOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationAnalyzerIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationAnalyzerIT.java index 335ec1a2c82..7fa5b6a9dda 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationAnalyzerIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationAnalyzerIT.java @@ -10,55 +10,50 @@ import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.hasValidationFailureReport; import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.ElasticsearchIndexSchemaManagerAnalyzerITAnalysisConfigurer; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportChecker; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to analyzers when validating indexes, * for all index-validating schema management operations. */ -@RunWith(Parameterized.class) @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.ElasticsearchAnalyzerDefinitionValidationIT") -public class ElasticsearchIndexSchemaManagerValidationAnalyzerIT { +class ElasticsearchIndexSchemaManagerValidationAnalyzerIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerValidationOperation.all(); + public static List params() { + return ElasticsearchIndexSchemaManagerValidationOperation.all().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final ElasticsearchIndexSchemaManagerValidationOperation operation; - - public ElasticsearchIndexSchemaManagerValidationAnalyzerIT( - ElasticsearchIndexSchemaManagerValidationOperation operation) { - this.operation = operation; - } - - @Test - public void success_simple() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_simple(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -109,13 +104,14 @@ public void success_simple() throws Exception { putMapping(); - setupAndValidate(); + setupAndValidate( operation ); // If we get here, it means validation passed (no exception was thrown) } - @Test - public void analyzer_missing() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void analyzer_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -152,12 +148,14 @@ public void analyzer_missing() throws Exception { setupAndValidateExpectingFailure( hasValidationFailureReport() .analyzerContext( "custom-analyzer" ) - .failure( "Missing analyzer" ) + .failure( "Missing analyzer" ), + operation ); } - @Test - public void analyzer_charFilters_invalid() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void analyzer_charFilters_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -204,12 +202,14 @@ public void analyzer_charFilters_invalid() throws Exception { .failure( "Invalid char filters. Expected '[custom-pattern-replace]'," + " actual is '[html_strip]'" - ) + ), + operation ); } - @Test - public void analyzer_tokenizer_invalid() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void analyzer_tokenizer_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -256,12 +256,14 @@ public void analyzer_tokenizer_invalid() throws Exception { .failure( "Invalid tokenizer. Expected 'custom-edgeNGram'," + " actual is 'whitespace'" - ) + ), + operation ); } - @Test - public void analyzer_tokenFilters_invalid() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void analyzer_tokenFilters_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -308,12 +310,14 @@ public void analyzer_tokenFilters_invalid() throws Exception { .failure( "Invalid token filters. Expected '[custom-keep-types, custom-word-delimiter]'," + " actual is '[lowercase, custom-word-delimiter]'" - ) + ), + operation ); } - @Test - public void charFilter_missing() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void charFilter_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -344,12 +348,14 @@ public void charFilter_missing() throws Exception { .analyzerContext( "custom-analyzer" ) .failure( "Missing analyzer" ) .charFilterContext( "custom-pattern-replace" ) - .failure( "Missing char filter" ) + .failure( "Missing char filter" ), + operation ); } - @Test - public void tokenizer_missing() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void tokenizer_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -381,12 +387,14 @@ public void tokenizer_missing() throws Exception { .analyzerContext( "custom-analyzer" ) .failure( "Missing analyzer" ) .tokenizerContext( "custom-edgeNGram" ) - .failure( "Missing tokenizer" ) + .failure( "Missing tokenizer" ), + operation ); } - @Test - public void tokenFilter_missing() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void tokenFilter_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -415,12 +423,14 @@ public void tokenFilter_missing() throws Exception { .analyzerContext( "custom-analyzer" ) .failure( "Missing analyzer" ) .tokenFilterContext( "custom-keep-types" ) - .failure( "Missing token filter" ) + .failure( "Missing token filter" ), + operation ); } - @Test - public void charFilter_type_invalid() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void charFilter_type_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -466,12 +476,14 @@ public void charFilter_type_invalid() throws Exception { .charFilterContext( "custom-pattern-replace" ) .failure( "Invalid type. Expected 'pattern_replace', actual is 'html_strip'" - ) + ), + operation ); } - @Test - public void charFilter_parameter_invalid() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void charFilter_parameter_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -518,12 +530,14 @@ public void charFilter_parameter_invalid() throws Exception { .analysisDefinitionParameterContext( "pattern" ) .failure( "Invalid value. Expected '\"[^0-9]\"', actual is '\"[^a-z]\"'" - ) + ), + operation ); } - @Test - public void charFilter_parameter_missing() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void charFilter_parameter_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -570,12 +584,15 @@ public void charFilter_parameter_missing() throws Exception { .analysisDefinitionParameterContext( "tags" ) .failure( "Invalid value. Expected '\"CASE_INSENSITIVE|COMMENTS\"', actual is 'null'" - ) + ), + operation ); } - @Test - public void tokenFilter_parameter_unexpected() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void tokenFilter_parameter_unexpected(ElasticsearchIndexSchemaManagerValidationOperation operation) + throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -623,17 +640,19 @@ public void tokenFilter_parameter_unexpected() throws Exception { .analysisDefinitionParameterContext( "generate_number_parts" ) .failure( "Invalid value. Expected 'null', actual is '\"false\"'" - ) + ), + operation ); } - private void setupAndValidateExpectingFailure(FailureReportChecker failureReportChecker) { - assertThatThrownBy( this::setupAndValidate ) + private void setupAndValidateExpectingFailure(FailureReportChecker failureReportChecker, + ElasticsearchIndexSchemaManagerValidationOperation operation) { + assertThatThrownBy( () -> setupAndValidate( operation ) ) .isInstanceOf( SearchException.class ) .satisfies( failureReportChecker ); } - private void setupAndValidate() { + private void setupAndValidate(ElasticsearchIndexSchemaManagerValidationOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationCustomMappingIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationCustomMappingIT.java index faa87528a11..eb93b2769f7 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationCustomMappingIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationCustomMappingIT.java @@ -9,51 +9,47 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.hasValidationFailureReport; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to index custom mapping when validating indexes, * for all index-validating schema management operations. */ -@RunWith(Parameterized.class) -public class ElasticsearchIndexSchemaManagerValidationCustomMappingIT { +class ElasticsearchIndexSchemaManagerValidationCustomMappingIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerValidationOperation.all(); + public static List params() { + return ElasticsearchIndexSchemaManagerValidationOperation.all().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final ElasticsearchIndexSchemaManagerValidationOperation operation; - public ElasticsearchIndexSchemaManagerValidationCustomMappingIT( - ElasticsearchIndexSchemaManagerValidationOperation operation) { - this.operation = operation; - } - - @Test - public void success() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate(); elasticsearchClient.index( index.name() ).type().putMapping( " { " + @@ -80,11 +76,12 @@ public void success() { " } " ); - setupAndValidate( "no-overlapping.json" ); + setupAndValidate( "no-overlapping.json", operation ); } - @Test - public void wrongSource() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void wrongSource(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate(); elasticsearchClient.index( index.name() ).type().putMapping( " { " + @@ -111,7 +108,7 @@ public void wrongSource() { " } " ); - assertThatThrownBy( () -> setupAndValidate( "no-overlapping.json" ) ) + assertThatThrownBy( () -> setupAndValidate( "no-overlapping.json", operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .mappingAttributeContext( "_source" ) @@ -119,8 +116,9 @@ public void wrongSource() { .failure( "Custom index mapping attribute missing" ) ); } - @Test - public void missingSource() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void missingSource(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate(); elasticsearchClient.index( index.name() ).type().putMapping( " { " + @@ -144,15 +142,16 @@ public void missingSource() { " } " ); - assertThatThrownBy( () -> setupAndValidate( "no-overlapping.json" ) ) + assertThatThrownBy( () -> setupAndValidate( "no-overlapping.json", operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .mappingAttributeContext( "_source" ) .failure( "Custom index mapping attribute missing" ) ); } - @Test - public void wrongField() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void wrongField(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate(); elasticsearchClient.index( index.name() ).type().putMapping( " { " + @@ -178,7 +177,7 @@ public void wrongField() { " } " ); - assertThatThrownBy( () -> setupAndValidate( "no-overlapping.json" ) ) + assertThatThrownBy( () -> setupAndValidate( "no-overlapping.json", operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "userField" ) @@ -192,8 +191,9 @@ public void wrongField() { .failure( "Invalid value. Expected 'true', actual is 'false'" ) ); } - @Test - public void missingField() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void missingField(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate(); elasticsearchClient.index( index.name() ).type().putMapping( " { " + @@ -214,14 +214,14 @@ public void missingField() { " } " ); - assertThatThrownBy( () -> setupAndValidate( "no-overlapping.json" ) ) + assertThatThrownBy( () -> setupAndValidate( "no-overlapping.json", operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "userField" ) .failure( "Missing property mapping" ) ); } - private void setupAndValidate(String customMappingFile) { + private void setupAndValidate(String customMappingFile, ElasticsearchIndexSchemaManagerValidationOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationCustomSettingsIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationCustomSettingsIT.java index 945d84cae8e..fcfd4a36846 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationCustomSettingsIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationCustomSettingsIT.java @@ -10,53 +10,48 @@ import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.hasValidationFailureReport; import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportChecker; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to index custom settings when validating indexes, * for all index-validating schema management operations. */ -@RunWith(Parameterized.class) -public class ElasticsearchIndexSchemaManagerValidationCustomSettingsIT { +class ElasticsearchIndexSchemaManagerValidationCustomSettingsIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerValidationOperation.all(); + public static List params() { + return ElasticsearchIndexSchemaManagerValidationOperation.all().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final ElasticsearchIndexSchemaManagerValidationOperation operation; - - public ElasticsearchIndexSchemaManagerValidationCustomSettingsIT( - ElasticsearchIndexSchemaManagerValidationOperation operation) { - this.operation = operation; - } - - @Test - public void success_simple() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_simple(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", " { " + " 'number_of_shards': '3', " + @@ -87,13 +82,14 @@ public void success_simple() { simpleMappingForInitialization( "" ) ); - setupAndValidate(); + setupAndValidate( operation ); // If we get here, it means validation passed (no exception was thrown) } - @Test - public void invalid_analysis() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void invalid_analysis(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", " { " + " 'number_of_shards': '3', " + @@ -134,12 +130,14 @@ public void invalid_analysis() { .analysisDefinitionParameterContext( "max_gram" ) .failure( "Invalid value. Expected '\"6\"', actual is '\"3\"'" - ) + ), + operation ); } - @Test - public void invalid_numberOfShards() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void invalid_numberOfShards(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", " { " + " 'number_of_shards': '7', " + @@ -175,19 +173,21 @@ public void invalid_numberOfShards() { .indexSettingsCustomAttributeContext( "number_of_shards" ) .failure( "Invalid value. Expected '\"3\"', actual is '\"7\"'" - ) + ), + operation ); } - @Test - public void invalid_maxResultWindow() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void invalid_maxResultWindow(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", "{ 'max_result_window': '20000' }" ); elasticsearchClient.index( index.name() ).type().putMapping( simpleMappingForInitialization( "" ) ); - assertThatThrownBy( () -> setupAndValidate( "max-result-window.json" ) ) + assertThatThrownBy( () -> setupAndValidate( "max-result-window.json", operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexSettingsCustomAttributeContext( "max_result_window" ) @@ -196,41 +196,44 @@ public void invalid_maxResultWindow() { ) ); } - @Test - public void default_maxResultWindow() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void default_maxResultWindow(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", "{ 'max_result_window': '10000' }" ); elasticsearchClient.index( index.name() ).type().putMapping( simpleMappingForInitialization( "" ) ); - setupAndValidate( null ); + setupAndValidate( null, operation ); // If we get here, it means validation passed (no exception was thrown) } - @Test - public void empty() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void empty(ElasticsearchIndexSchemaManagerValidationOperation operation) { elasticsearchClient.index( index.name() ).deleteAndCreate( "index", "{ }" ); elasticsearchClient.index( index.name() ).type().putMapping( simpleMappingForInitialization( "" ) ); - setupAndValidate( null ); + setupAndValidate( null, operation ); // If we get here, it means validation passed (no exception was thrown) } - private void setupAndValidateExpectingFailure(FailureReportChecker failureReportChecker) { - assertThatThrownBy( this::setupAndValidate ) + private void setupAndValidateExpectingFailure(FailureReportChecker failureReportChecker, + ElasticsearchIndexSchemaManagerValidationOperation operation) { + assertThatThrownBy( () -> setupAndValidate( operation ) ) .isInstanceOf( SearchException.class ) .satisfies( failureReportChecker ); } - private void setupAndValidate() { - setupAndValidate( "valid.json" ); + private void setupAndValidate(ElasticsearchIndexSchemaManagerValidationOperation operation) { + setupAndValidate( "valid.json", operation ); } - private void setupAndValidate(String customSettingsFile) { + private void setupAndValidate(String customSettingsFile, ElasticsearchIndexSchemaManagerValidationOperation operation) { SearchSetupHelper.SetupContext setupContext = setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingAttributeIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingAttributeIT.java index 9c94fdf7a54..14f18e84e5e 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingAttributeIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingAttributeIT.java @@ -11,7 +11,8 @@ import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.hasValidationFailureReport; import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; @@ -20,18 +21,18 @@ import org.hibernate.search.engine.backend.types.Searchable; import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.engine.backend.types.TermVector; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to mapping attributes when validating indexes, @@ -40,29 +41,23 @@ * These tests are more specific than {@link ElasticsearchIndexSchemaManagerValidationMappingBaseIT} * and focus on specific mapping attributes. */ -@RunWith(Parameterized.class) -public class ElasticsearchIndexSchemaManagerValidationMappingAttributeIT { +class ElasticsearchIndexSchemaManagerValidationMappingAttributeIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerValidationOperation.all(); + public static List params() { + return ElasticsearchIndexSchemaManagerValidationOperation.all().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); - private final ElasticsearchIndexSchemaManagerValidationOperation operation; - - public ElasticsearchIndexSchemaManagerValidationMappingAttributeIT( - ElasticsearchIndexSchemaManagerValidationOperation operation) { - this.operation = operation; - } - - @Test - public void attribute_dynamic_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_dynamic_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger() ).toReference() ); @@ -80,15 +75,16 @@ public void attribute_dynamic_missing() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .mappingAttributeContext( "dynamic" ) .failure( "Invalid value. Expected 'STRICT', actual is 'null'" ) ); } - @Test - public void attribute_dynamic_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_dynamic_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger() ).toReference() ); @@ -107,7 +103,7 @@ public void attribute_dynamic_invalid() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .mappingAttributeContext( "dynamic" ) @@ -115,8 +111,9 @@ public void attribute_dynamic_invalid() { } - @Test - public void attribute_properties_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_properties_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger() ).toReference() ); @@ -128,7 +125,7 @@ public void attribute_properties_missing() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "_entity_type" ) @@ -137,8 +134,9 @@ public void attribute_properties_missing() { .failure( "Missing property mapping" ) ); } - @Test - public void attribute_properties_empty() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_properties_empty(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger() ).toReference() ); @@ -152,7 +150,7 @@ public void attribute_properties_empty() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "_entity_type" ) @@ -161,8 +159,9 @@ public void attribute_properties_empty() { .failure( "Missing property mapping" ) ); } - @Test - public void attribute_type_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_type_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger() ).toReference() ); @@ -177,7 +176,7 @@ public void attribute_type_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -185,8 +184,9 @@ public void attribute_type_invalid() { .failure( "Invalid value. Expected 'integer', actual is 'keyword'" ) ); } - @Test - public void attribute_index_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_index_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger() ).toReference() ); @@ -201,11 +201,12 @@ public void attribute_index_missing() { ); // the expected value true is the default - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_index_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_index_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger().searchable( Searchable.YES ) ).toReference() ); @@ -221,11 +222,12 @@ public void attribute_index_valid() { ); // the expected value true is the default - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_index_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_index_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger() ).toReference() ); @@ -240,7 +242,7 @@ public void attribute_index_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -248,8 +250,9 @@ public void attribute_index_invalid() { .failure( "Invalid value. Expected 'true', actual is 'false'" ) ); } - @Test - public void attribute_index_false_scalar() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_index_false_scalar(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( // Searchable.NO allows "index" being set to false root -> root.field( "myField", f -> f.asInteger().searchable( Searchable.NO ) ).toReference() @@ -265,11 +268,12 @@ public void attribute_index_false_scalar() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_index_false_text() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_index_false_text(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( // Searchable.NO allows "index" being set to false root -> root.field( "myField", f -> f.asString().analyzer( "keyword" ).searchable( Searchable.NO ) ) @@ -287,11 +291,12 @@ public void attribute_index_false_text() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_format_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_format_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asLocalDate() ).toReference() ); @@ -307,7 +312,7 @@ public void attribute_format_missing() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -319,8 +324,9 @@ public void attribute_format_missing() { ) ); } - @Test - public void attribute_format_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_format_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asLocalDate() ).toReference() ); @@ -337,11 +343,12 @@ public void attribute_format_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_format_exceeding() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_format_exceeding(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asLocalDate() ).toReference() ); @@ -358,7 +365,7 @@ public void attribute_format_exceeding() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -369,8 +376,9 @@ public void attribute_format_exceeding() { ) ); } - @Test - public void attribute_format_wrong() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_format_wrong(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asLocalDate() ).toReference() ); @@ -385,7 +393,7 @@ public void attribute_format_wrong() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -397,8 +405,9 @@ public void attribute_format_wrong() { ) ); } - @Test - public void attribute_analyzer_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_analyzer_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "keyword" ) ).toReference() ); @@ -413,7 +422,7 @@ public void attribute_analyzer_missing() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -421,8 +430,9 @@ public void attribute_analyzer_missing() { .failure( "Invalid value. Expected 'keyword', actual is 'null'" ) ); } - @Test - public void attribute_analyzer_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_analyzer_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "keyword" ) ).toReference() ); @@ -438,11 +448,12 @@ public void attribute_analyzer_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_analyzer_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_analyzer_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "default" ) ).toReference() ); @@ -458,7 +469,7 @@ public void attribute_analyzer_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -466,8 +477,9 @@ public void attribute_analyzer_invalid() { .failure( "Invalid value. Expected 'default', actual is 'keyword'" ) ); } - @Test - public void attribute_searchAnalyzer_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_searchAnalyzer_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString() .analyzer( "keyword" ).searchAnalyzer( "italian" ) ).toReference() @@ -484,7 +496,7 @@ public void attribute_searchAnalyzer_missing() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -492,8 +504,9 @@ public void attribute_searchAnalyzer_missing() { .failure( "Invalid value. Expected 'italian', actual is 'null'" ) ); } - @Test - public void attribute_searchAnalyzer_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_searchAnalyzer_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString() .analyzer( "keyword" ).searchAnalyzer( "english" ) ).toReference() @@ -511,11 +524,12 @@ public void attribute_searchAnalyzer_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_searchAnalyzer_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_searchAnalyzer_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "keyword" ).searchAnalyzer( "italian" ) ) .toReference() @@ -533,7 +547,7 @@ public void attribute_searchAnalyzer_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -542,9 +556,10 @@ public void attribute_searchAnalyzer_invalid() { } - @Test + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4652") - public void attribute_searchAnalyzer_sameAsAnalyzer_valid() { + void attribute_searchAnalyzer_sameAsAnalyzer_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString() .analyzer( "keyword" ).searchAnalyzer( "keyword" ) ).toReference() @@ -562,12 +577,13 @@ public void attribute_searchAnalyzer_sameAsAnalyzer_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4652") - public void attribute_searchAnalyzer_sameAsAnalyzer_invalid() { + void attribute_searchAnalyzer_sameAsAnalyzer_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "keyword" ).searchAnalyzer( "keyword" ) ) .toReference() @@ -585,7 +601,7 @@ public void attribute_searchAnalyzer_sameAsAnalyzer_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -593,8 +609,9 @@ public void attribute_searchAnalyzer_sameAsAnalyzer_invalid() { .failure( "Invalid value. Expected 'keyword', actual is 'english'" ) ); } - @Test - public void property_norms_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void property_norms_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "default" ).norms( Norms.NO ) ).toReference() ); @@ -609,11 +626,12 @@ public void property_norms_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void property_norms_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void property_norms_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "default" ).norms( Norms.YES ) ).toReference() ); @@ -628,7 +646,7 @@ public void property_norms_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -637,8 +655,9 @@ public void property_norms_invalid() { ); } - @Test - public void property_norms_missing_textField() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void property_norms_missing_textField(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "default" ).norms( Norms.YES ) ).toReference() ); @@ -652,11 +671,12 @@ public void property_norms_missing_textField() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void property_norms_missing_keywordField() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void property_norms_missing_keywordField(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().norms( Norms.NO ) ).toReference() ); @@ -670,11 +690,12 @@ public void property_norms_missing_keywordField() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void property_termVector_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void property_termVector_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root .field( "myField", @@ -693,11 +714,12 @@ public void property_termVector_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void property_termVector_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void property_termVector_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "english" ).termVector( TermVector.NO ) ) .toReference() @@ -713,11 +735,12 @@ public void property_termVector_missing() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void property_termVector_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void property_termVector_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().analyzer( "english" ).termVector( TermVector.YES ) ) .toReference() @@ -734,7 +757,7 @@ public void property_termVector_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -742,8 +765,9 @@ public void property_termVector_invalid() { .failure( "Invalid value. Expected 'yes', actual is 'with_offsets'" ) ); } - @Test - public void attribute_nullValue_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_nullValue_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger().indexNullAs( 739 ) ).toReference() ); @@ -758,11 +782,12 @@ public void attribute_nullValue_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_nullValue_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_nullValue_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger().indexNullAs( 739 ) ).toReference() ); @@ -776,7 +801,7 @@ public void attribute_nullValue_missing() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -784,8 +809,9 @@ public void attribute_nullValue_missing() { .failure( "Invalid value. Expected '739', actual is 'null'" ) ); } - @Test - public void attribute_nullValue_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_nullValue_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger().indexNullAs( 739 ) ).toReference() ); @@ -800,7 +826,7 @@ public void attribute_nullValue_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -808,8 +834,9 @@ public void attribute_nullValue_invalid() { .failure( "Invalid value. Expected '739', actual is '777'" ) ); } - @Test - public void attribute_docValues_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_docValues_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger().sortable( Sortable.YES ) ).toReference() ); @@ -824,11 +851,12 @@ public void attribute_docValues_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_docValues_default() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_docValues_default(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger().sortable( Sortable.YES ) ).toReference() ); @@ -842,11 +870,12 @@ public void attribute_docValues_default() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_docValues_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_docValues_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger().sortable( Sortable.YES ) ).toReference() ); @@ -861,7 +890,7 @@ public void attribute_docValues_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -869,8 +898,9 @@ public void attribute_docValues_invalid() { .failure( "Invalid value. Expected 'true', actual is 'false'" ) ); } - @Test - public void attribute_docValues_false() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_docValues_false(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( // Sortable.NO and Sortable.DEFAULT allow doc_values being set to false root -> root.field( "myField", f -> f.asInteger() ).toReference() @@ -886,11 +916,12 @@ public void attribute_docValues_false() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_docValues_skip() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_docValues_skip(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( // Sortable.NO and Sortable.DEFAULT do not require doc_values being set to false root -> root.field( "myField", f -> f.asString().sortable( Sortable.NO ) ).toReference() @@ -906,11 +937,12 @@ public void attribute_docValues_skip() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_scaling_factor_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_scaling_factor_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asBigDecimal().decimalScale( 2 ) ).toReference() ); @@ -925,11 +957,12 @@ public void attribute_scaling_factor_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_scaling_factor_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_scaling_factor_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asBigDecimal().decimalScale( 2 ) ).toReference() ); @@ -944,7 +977,7 @@ public void attribute_scaling_factor_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -952,8 +985,9 @@ public void attribute_scaling_factor_invalid() { .failure( "Invalid value. Expected '100.0', actual is '2.0'" ) ); } - @Test - public void attribute_normalizer_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_normalizer_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().normalizer( "default" ) ).toReference() ); @@ -968,7 +1002,7 @@ public void attribute_normalizer_missing() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -976,8 +1010,9 @@ public void attribute_normalizer_missing() { .failure( "Invalid value. Expected 'default', actual is 'null'" ) ); } - @Test - public void attribute_normalizer_valid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_normalizer_valid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().normalizer( "custom-normalizer" ) ).toReference() ); @@ -1015,11 +1050,12 @@ public void attribute_normalizer_valid() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_normalizer_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_normalizer_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asString().normalizer( "another-normalizer" ) ).toReference() ); @@ -1057,7 +1093,7 @@ public void attribute_normalizer_invalid() { ) ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( Exception.class ) .satisfies( hasValidationFailureReport() .indexFieldContext( "myField" ) @@ -1065,7 +1101,7 @@ public void attribute_normalizer_invalid() { .failure( "Invalid value. Expected 'another-normalizer', actual is 'custom-normalizer'" ) ); } - private void setupAndValidate(StubMappedIndex index) { + private void setupAndValidate(StubMappedIndex index, ElasticsearchIndexSchemaManagerValidationOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingBaseIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingBaseIT.java index 50b57b89dc0..c15ec0616c9 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingBaseIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingBaseIT.java @@ -11,55 +11,50 @@ import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.hasValidationFailureReport; import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.ElasticsearchExtension; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportChecker; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Basic tests related to the mapping when validating indexes, * for all index-validating schema management operations. */ -@RunWith(Parameterized.class) @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.Elasticsearch5SchemaValidationIT") -public class ElasticsearchIndexSchemaManagerValidationMappingBaseIT { +class ElasticsearchIndexSchemaManagerValidationMappingBaseIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerValidationOperation.all(); + public static List params() { + return ElasticsearchIndexSchemaManagerValidationOperation.all().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); - private final ElasticsearchIndexSchemaManagerValidationOperation operation; - - public ElasticsearchIndexSchemaManagerValidationMappingBaseIT( - ElasticsearchIndexSchemaManagerValidationOperation operation) { - this.operation = operation; - } - - @Test - public void success_1() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_1(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "myField", f -> f.asLocalDate() ) .toReference(); @@ -82,13 +77,14 @@ public void success_1() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); // If we get here, it means validation passed (no exception was thrown) } - @Test - public void success_2() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_2(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "myField", f -> f.asBoolean() ) .toReference(); @@ -108,13 +104,14 @@ public void success_2() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); // If we get here, it means validation passed (no exception was thrown) } - @Test - public void success_3() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_3(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "myField", @@ -138,11 +135,12 @@ public void success_3() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void attribute_field_notPresent() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_field_notPresent(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "myField", f -> f.asInteger() ).toReference() ); @@ -161,15 +159,17 @@ public void attribute_field_notPresent() { index, hasValidationFailureReport() .indexFieldContext( "myField" ) - .failure( "Missing property mapping" ) + .failure( "Missing property mapping" ), + operation ); } /** * Tests that mappings that are more powerful than requested will pass validation. */ - @Test - public void property_attribute_leniency() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void property_attribute_leniency(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "myField", f -> f.asLong() ) .toReference(); @@ -193,11 +193,12 @@ public void property_attribute_leniency() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void floatAndDouble_nullValue() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void floatAndDouble_nullValue(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "float", f -> f.asFloat().indexNullAs( 1.7F ) ).toReference(); root.field( "double", f -> f.asDouble().indexNullAs( 1.7 ) ).toReference(); @@ -217,11 +218,12 @@ public void floatAndDouble_nullValue() { ) ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void floatAndDouble_nullValue_invalids() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void floatAndDouble_nullValue_invalids(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "float", f -> f.asFloat().indexNullAs( 1.7F ) ).toReference(); root.field( "double", f -> f.asDouble().indexNullAs( 1.7 ) ).toReference(); @@ -248,12 +250,14 @@ public void floatAndDouble_nullValue_invalids() { .failure( "Invalid value. Expected '1.7', actual is '1.9'" ) .indexFieldContext( "float" ) .mappingAttributeContext( "null_value" ) - .failure( "Invalid value. Expected '1.7', actual is '1.9'" ) + .failure( "Invalid value. Expected '1.7', actual is '1.9'" ), + operation ); } - @Test - public void floatAndDouble_nullValue_invalids_notNumbers() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void floatAndDouble_nullValue_invalids_notNumbers(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "float", f -> f .extension( ElasticsearchExtension.get() ) @@ -286,15 +290,17 @@ public void floatAndDouble_nullValue_invalids_notNumbers() { .failure( "Invalid value. Expected '\"BBB\"', actual is '1.9'" ) .indexFieldContext( "float" ) .mappingAttributeContext( "null_value" ) - .failure( "Invalid value. Expected '\"AAA\"', actual is '1.9'" ) + .failure( "Invalid value. Expected '\"AAA\"', actual is '1.9'" ), + operation ); } /** * Tests that properties within properties are correctly represented in the failure report. */ - @Test - public void nestedProperty_attribute_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void nestedProperty_attribute_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { IndexSchemaObjectField objectField = root.objectField( "myObjectField" ); @@ -326,12 +332,14 @@ public void nestedProperty_attribute_invalid() { hasValidationFailureReport() .indexFieldContext( "myObjectField.myField" ) .mappingAttributeContext( "index" ) - .failure( "Invalid value. Expected 'true', actual is 'false'" ) + .failure( "Invalid value. Expected 'true', actual is 'false'" ), + operation ); } - @Test - public void multipleErrors() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void multipleErrors(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.field( "myField", f -> f.asString() ) .toReference(); @@ -361,17 +369,19 @@ public void multipleErrors() { .mappingAttributeContext( "type" ) .failure( "Invalid value. Expected 'keyword', actual is 'integer'" - ) + ), + operation ); } - private void setupAndValidateExpectingFailure(StubMappedIndex index, FailureReportChecker failureReportChecker) { - assertThatThrownBy( () -> setupAndValidate( index ) ) + private void setupAndValidateExpectingFailure(StubMappedIndex index, FailureReportChecker failureReportChecker, + ElasticsearchIndexSchemaManagerValidationOperation operation) { + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( failureReportChecker ); } - private void setupAndValidate(StubMappedIndex index) { + private void setupAndValidate(StubMappedIndex index, ElasticsearchIndexSchemaManagerValidationOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingFieldTemplateIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingFieldTemplateIT.java index 17555c19261..aec78271e1f 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingFieldTemplateIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationMappingFieldTemplateIT.java @@ -10,23 +10,24 @@ import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.defaultMetadataMappingForInitialization; import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.hasValidationFailureReport; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext; import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.engine.backend.types.ObjectStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to field templates when validating indexes, @@ -35,29 +36,23 @@ * These tests are more specific than {@link ElasticsearchIndexSchemaManagerValidationMappingBaseIT} * and focus on field templates. */ -@RunWith(Parameterized.class) -public class ElasticsearchIndexSchemaManagerValidationMappingFieldTemplateIT { +class ElasticsearchIndexSchemaManagerValidationMappingFieldTemplateIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerValidationOperation.all(); + public static List params() { + return ElasticsearchIndexSchemaManagerValidationOperation.all().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); - private final ElasticsearchIndexSchemaManagerValidationOperation operation; - - public ElasticsearchIndexSchemaManagerValidationMappingFieldTemplateIT( - ElasticsearchIndexSchemaManagerValidationOperation operation) { - this.operation = operation; - } - - @Test - public void success() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ) .matchingPathGlob( "*_t1" ); @@ -96,11 +91,12 @@ public void success() { + "}" ); - setupAndValidate( index ); + setupAndValidate( index, operation ); } - @Test - public void missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ); root.fieldTemplate( "myTemplate2", f -> f.asString().analyzer( "default" ) ); @@ -126,15 +122,16 @@ public void missing() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate2" ) .failure( "Missing dynamic field template" ) ); } - @Test - public void extra() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void extra(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ); root.fieldTemplate( "myTemplate2", f -> f.asString().analyzer( "default" ) ); @@ -168,15 +165,16 @@ public void extra() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "extraTemplate" ) .failure( "Unexpected dynamic field template" ) ); } - @Test - public void wrongOrder() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void wrongOrder(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ); root.fieldTemplate( "myTemplate2", f -> f.asString().analyzer( "default" ) ); @@ -206,7 +204,7 @@ public void wrongOrder() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .failure( @@ -216,8 +214,9 @@ public void wrongOrder() { ) ); } - @Test - public void duplicate() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void duplicate(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate1", f -> f.asInteger() ); } ); @@ -241,7 +240,7 @@ public void duplicate() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate1" ) @@ -251,8 +250,9 @@ public void duplicate() { ) ); } - @Test - public void attribute_pathMatch_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_pathMatch_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate", ObjectStructure.NESTED ) .matchingPathGlob( "*_suffix" ); @@ -273,7 +273,7 @@ public void attribute_pathMatch_missing() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate" ) @@ -281,8 +281,9 @@ public void attribute_pathMatch_missing() { .failure( "Invalid value. Expected '*_suffix', actual is 'null'" ) ); } - @Test - public void attribute_pathMatch_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_pathMatch_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate", ObjectStructure.NESTED ) .matchingPathGlob( "*_suffix" ); @@ -304,7 +305,7 @@ public void attribute_pathMatch_invalid() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate" ) @@ -312,8 +313,9 @@ public void attribute_pathMatch_invalid() { .failure( "Invalid value. Expected '*_suffix', actual is '*_suffix2'" ) ); } - @Test - public void attribute_pathMatch_extra() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_pathMatch_extra(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate", f -> f.asString() ); } ); @@ -333,7 +335,7 @@ public void attribute_pathMatch_extra() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate" ) @@ -341,8 +343,9 @@ public void attribute_pathMatch_extra() { .failure( "Invalid value. Expected '*', actual is '*_suffix'" ) ); } - @Test - public void attribute_matchMappingType_missing() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_matchMappingType_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate", ObjectStructure.NESTED ); } ); @@ -362,7 +365,7 @@ public void attribute_matchMappingType_missing() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate" ) @@ -370,8 +373,9 @@ public void attribute_matchMappingType_missing() { .failure( "Invalid value. Expected 'object', actual is 'null'" ) ); } - @Test - public void attribute_matchMappingType_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_matchMappingType_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.objectFieldTemplate( "myTemplate", ObjectStructure.NESTED ); } ); @@ -392,7 +396,7 @@ public void attribute_matchMappingType_invalid() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate" ) @@ -400,8 +404,9 @@ public void attribute_matchMappingType_invalid() { .failure( "Invalid value. Expected 'object', actual is 'long'" ) ); } - @Test - public void attribute_matchMappingType_extra() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_matchMappingType_extra(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate", f -> f.asString() ); } ); @@ -422,7 +427,7 @@ public void attribute_matchMappingType_extra() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate" ) @@ -430,8 +435,9 @@ public void attribute_matchMappingType_extra() { .failure( "Invalid value. Expected 'null', actual is 'long'" ) ); } - @Test - public void attribute_extra() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void attribute_extra(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate", f -> f.asString() ); } ); @@ -452,7 +458,7 @@ public void attribute_extra() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate" ) @@ -460,8 +466,9 @@ public void attribute_extra() { .failure( "Invalid value. Expected 'null', actual is '\"*_suffix\"'" ) ); } - @Test - public void mapping_invalid() { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void mapping_invalid(ElasticsearchIndexSchemaManagerValidationOperation operation) { StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> { root.fieldTemplate( "myTemplate", f -> f.asString() ); } ); @@ -481,7 +488,7 @@ public void mapping_invalid() { + "}" ); - assertThatThrownBy( () -> setupAndValidate( index ) ) + assertThatThrownBy( () -> setupAndValidate( index, operation ) ) .isInstanceOf( SearchException.class ) .satisfies( hasValidationFailureReport() .indexFieldTemplateContext( "myTemplate" ) @@ -490,7 +497,7 @@ public void mapping_invalid() { .failure( "Invalid value. Expected 'keyword', actual is 'integer'" ) ); } - private void setupAndValidate(StubMappedIndex index) { + private void setupAndValidate(StubMappedIndex index, ElasticsearchIndexSchemaManagerValidationOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationNormalizerIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationNormalizerIT.java index 118eed6e956..28bad19b541 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationNormalizerIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/schema/management/ElasticsearchIndexSchemaManagerValidationNormalizerIT.java @@ -10,54 +10,49 @@ import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.hasValidationFailureReport; import static org.hibernate.search.integrationtest.backend.elasticsearch.schema.management.ElasticsearchIndexSchemaManagerTestUtils.simpleMappingForInitialization; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.ElasticsearchIndexSchemaManagerNormalizerITAnalysisConfigurer; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportChecker; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests related to normalizers when validating indexes, * for all index-validating schema management operations. */ -@RunWith(Parameterized.class) @PortedFromSearch5(original = "org.hibernate.search.elasticsearch.test.ElasticsearchNormalizerDefinitionValidationIT") -public class ElasticsearchIndexSchemaManagerValidationNormalizerIT { +class ElasticsearchIndexSchemaManagerValidationNormalizerIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return ElasticsearchIndexSchemaManagerValidationOperation.all(); + public static List params() { + return ElasticsearchIndexSchemaManagerValidationOperation.all().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticSearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticSearchClient = TestElasticsearchClient.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final ElasticsearchIndexSchemaManagerValidationOperation operation; - - public ElasticsearchIndexSchemaManagerValidationNormalizerIT( - ElasticsearchIndexSchemaManagerValidationOperation operation) { - this.operation = operation; - } - - @Test - public void success_simple() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void success_simple(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -84,13 +79,14 @@ public void success_simple() throws Exception { putMapping(); - setupAndValidate(); + setupAndValidate( operation ); // If we get here, it means validation passed (no exception was thrown) } - @Test - public void normalizer_missing() throws Exception { + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") + void normalizer_missing(ElasticsearchIndexSchemaManagerValidationOperation operation) throws Exception { elasticSearchClient.index( index.name() ).deleteAndCreate( "index.analysis", "{" @@ -114,17 +110,19 @@ public void normalizer_missing() throws Exception { setupAndValidateExpectingFailure( hasValidationFailureReport() .normalizerContext( "custom-normalizer" ) - .failure( "Missing normalizer" ) + .failure( "Missing normalizer" ), + operation ); } - private void setupAndValidateExpectingFailure(FailureReportChecker failureReportChecker) { - assertThatThrownBy( this::setupAndValidate ) + private void setupAndValidateExpectingFailure(FailureReportChecker failureReportChecker, + ElasticsearchIndexSchemaManagerValidationOperation operation) { + assertThatThrownBy( () -> setupAndValidate( operation ) ) .isInstanceOf( SearchException.class ) .satisfies( failureReportChecker ); } - private void setupAndValidate() { + private void setupAndValidate(ElasticsearchIndexSchemaManagerValidationOperation operation) { setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY ) .withBackendProperty( diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchImplicitFieldsIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchImplicitFieldsIT.java index 8ec09953c05..a8137eddf3e 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchImplicitFieldsIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchImplicitFieldsIT.java @@ -16,15 +16,15 @@ import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.search.aggregation.AggregationKey; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchImplicitFieldsIT { +class ElasticsearchImplicitFieldsIT { private static final String FIRST_ID = "1"; private static final String SECOND_ID = "2"; @@ -33,20 +33,20 @@ public class ElasticsearchImplicitFieldsIT { private static final String FIFTH_ID = "5"; private static final String EMPTY_ID = "empty"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndexes( mainIndex ).setup().integration(); initData(); } @Test - public void implicit_fields_aggregation_entity_type() { + void implicit_fields_aggregation_entity_type() { StubMappingScope scope = mainIndex.createScope(); AggregationKey> countsByEntityKey = AggregationKey.of( "countsByEntity" ); @@ -61,7 +61,7 @@ public void implicit_fields_aggregation_entity_type() { } @Test - public void implicit_fields_id() { + void implicit_fields_id() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() .where( f -> f.terms().field( "_id" ).matchingAny( "4" ) ) @@ -71,7 +71,7 @@ public void implicit_fields_id() { } @Test - public void implicit_fields_index() { + void implicit_fields_index() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() .where( f -> f.match().field( "_index" ).matching( "main-000001" ) ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchMatchSearchPredicateIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchMatchSearchPredicateIT.java index 51a298a8424..b3538c0c1f2 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchMatchSearchPredicateIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchMatchSearchPredicateIT.java @@ -11,32 +11,32 @@ import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchMatchSearchPredicateIT { +class ElasticsearchMatchSearchPredicateIT { private static final String TEST_TERM = "ThisWillBeLowercasedByTheNormalizer"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void match_skipAnalysis_normalizedStringField() { + void match_skipAnalysis_normalizedStringField() { assertThatThrownBy( () -> index.createScope().query() .where( f -> f.match().field( "normalizedStringField" ).matching( TEST_TERM ).skipAnalysis() ) .toQuery() diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchShardsFailedExceptionIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchShardsFailedExceptionIT.java index 044302353e7..a7e119fa895 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchShardsFailedExceptionIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/ElasticsearchShardsFailedExceptionIT.java @@ -17,19 +17,19 @@ import org.hibernate.search.engine.search.predicate.SearchPredicate; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchShardsFailedExceptionIT { +class ElasticsearchShardsFailedExceptionIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ).name( "index1" ); private final SimpleMappedIndex index2 = SimpleMappedIndex.of( IndexBinding::new ).name( "index2" ); @@ -53,7 +53,7 @@ public void setup(boolean ignoreShardFailures) { } @Test - public void failureFetch() { + void failureFetch() { setup( false ); SearchQuery query = createQuery(); @@ -66,7 +66,7 @@ public void failureFetch() { } @Test - public void failureScroll() { + void failureScroll() { setup( false ); SearchQuery query = createQuery(); @@ -79,7 +79,7 @@ public void failureScroll() { } @Test - public void success() { + void success() { setup( true ); SearchQuery query = createQuery(); assertThatHits( query.fetchAllHits() ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchBoolSearchPredicateIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchBoolSearchPredicateIT.java index 9c73e3739df..831ea7fdc37 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchBoolSearchPredicateIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchBoolSearchPredicateIT.java @@ -13,27 +13,27 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ElasticsearchBoolSearchPredicateIT { +class ElasticsearchBoolSearchPredicateIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void resultingQueryOptimization() { + void resultingQueryOptimization() { SearchPredicateFactory f = index.createScope().predicate(); assertJsonEqualsIgnoringUnknownFields( @@ -129,7 +129,7 @@ public void resultingQueryOptimization() { } @Test - public void resultingQueryOptimizationWithBoost() { + void resultingQueryOptimizationWithBoost() { SearchPredicateFactory f = index.createScope().predicate(); assertJsonEqualsIgnoringUnknownFields( @@ -179,7 +179,7 @@ public void resultingQueryOptimizationWithBoost() { } @Test - public void nested() { + void nested() { String expectedQueryJson = "{" + " \"query\": {" + " \"bool\": {" + @@ -256,7 +256,7 @@ public void nested() { } @Test - public void onlyNested() { + void onlyNested() { //bool query remains as there are > 1 clause assertJsonEqualsIgnoringUnknownFields( "{" + diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchSearchQueryIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchSearchQueryIT.java index fe3844b9602..7242c20788c 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchSearchQueryIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchSearchQueryIT.java @@ -9,6 +9,9 @@ import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.defaultReadAlias; import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.encodeName; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; import org.hibernate.search.backend.elasticsearch.cfg.impl.ElasticsearchBackendImplSettings; import org.hibernate.search.backend.elasticsearch.client.impl.Paths; @@ -21,15 +24,14 @@ import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.StubSingleIndexLayoutStrategy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchClientSpy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchRequestAssertionMode; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -37,36 +39,25 @@ /** * Test the content of generated Elasticsearch search queries. */ -@RunWith(Parameterized.class) -public class ElasticsearchSearchQueryIT { +class ElasticsearchSearchQueryIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Parameterized.Parameters(name = "IndexLayoutStrategy = {0}") - public static Object[][] configurations() { - return new Object[][] { - { null, defaultReadAlias( index.name() ) }, - { "no-alias", encodeName( index.name() ) }, - { new StubSingleIndexLayoutStrategy( "custom-write", "custom-read" ), encodeName( "custom-read" ) } - }; + public static List params() { + return Arrays.asList( + Arguments.of( null, defaultReadAlias( index.name() ) ), + Arguments.of( "no-alias", encodeName( index.name() ) ), + Arguments.of( new StubSingleIndexLayoutStrategy( "custom-write", "custom-read" ), encodeName( "custom-read" ) ) + ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public ElasticsearchClientSpy clientSpy = new ElasticsearchClientSpy(); + @RegisterExtension + public ElasticsearchClientSpy clientSpy = ElasticsearchClientSpy.create(); - private final Object layoutStrategy; - private final URLEncodedString readName; - - public ElasticsearchSearchQueryIT(Object layoutStrategy, URLEncodedString readName) { - this.layoutStrategy = layoutStrategy; - this.readName = readName; - } - - @Before - public void setup() { + public void init(Object layoutStrategy, URLEncodedString readName) { setupHelper.start() .withBackendProperty( ElasticsearchBackendImplSettings.CLIENT_FACTORY, clientSpy.factoryReference() @@ -78,8 +69,10 @@ public void setup() { .setup(); } - @Test - public void simple() { + @ParameterizedTest(name = "IndexLayoutStrategy = {0}") + @MethodSource("params") + void simple(Object layoutStrategy, URLEncodedString readName) { + init( layoutStrategy, readName ); StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -98,8 +91,10 @@ public void simple() { query.fetchAll(); } - @Test - public void defaultSourceFiltering() { + @ParameterizedTest(name = "IndexLayoutStrategy = {0}") + @MethodSource("params") + void defaultSourceFiltering(Object layoutStrategy, URLEncodedString readName) { + init( layoutStrategy, readName ); StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -118,8 +113,10 @@ public void defaultSourceFiltering() { query.fetchAll(); } - @Test - public void projection_sourceFiltering() { + @ParameterizedTest(name = "IndexLayoutStrategy = {0}") + @MethodSource("params") + void projection_sourceFiltering(Object layoutStrategy, URLEncodedString readName) { + init( layoutStrategy, readName ); StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -139,8 +136,10 @@ public void projection_sourceFiltering() { query.fetchAll(); } - @Test - public void routing() { + @ParameterizedTest(name = "IndexLayoutStrategy = {0}") + @MethodSource("params") + void routing(Object layoutStrategy, URLEncodedString readName) { + init( layoutStrategy, readName ); StubMappingScope scope = index.createScope(); String routingKey = "someRoutingKey"; @@ -163,8 +162,11 @@ public void routing() { query.fetchAll(); } - @Test - public void trackTotalHits_fetch() { + @ParameterizedTest(name = "IndexLayoutStrategy = {0}") + @MethodSource("params") + void trackTotalHits_fetch(Object layoutStrategy, URLEncodedString readName) { + init( layoutStrategy, readName ); + StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -184,8 +186,11 @@ public void trackTotalHits_fetch() { query.fetch( 30 ); } - @Test - public void trackTotalHits_fetchHits() { + @ParameterizedTest(name = "IndexLayoutStrategy = {0}") + @MethodSource("params") + void trackTotalHits_fetchHits(Object layoutStrategy, URLEncodedString readName) { + init( layoutStrategy, readName ); + StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchSearchQueryRequestTransformerIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchSearchQueryRequestTransformerIT.java index 94182db6e3f..313856ede67 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchSearchQueryRequestTransformerIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/search/query/ElasticsearchSearchQueryRequestTransformerIT.java @@ -23,13 +23,13 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchClientSpy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchRequestAssertionMode; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -40,19 +40,19 @@ * {@link ElasticsearchSearchRequestTransformer} * is used. */ -public class ElasticsearchSearchQueryRequestTransformerIT { +class ElasticsearchSearchQueryRequestTransformerIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public ElasticsearchClientSpy clientSpy = new ElasticsearchClientSpy(); + @RegisterExtension + public ElasticsearchClientSpy clientSpy = ElasticsearchClientSpy.create(); private final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); private final SimpleMappedIndex otherIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "other" ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start() .withBackendProperty( ElasticsearchBackendImplSettings.CLIENT_FACTORY, clientSpy.factoryReference() @@ -62,7 +62,7 @@ public void setup() { } @Test - public void path() { + void path() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query().extension( ElasticsearchExtension.get() ) @@ -89,7 +89,7 @@ public void path() { } @Test - public void queryParameters() { + void queryParameters() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query().extension( ElasticsearchExtension.get() ) @@ -118,7 +118,7 @@ public void queryParameters() { } @Test - public void body() { + void body() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query().extension( ElasticsearchExtension.get() ) diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchClientSpy.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchClientSpy.java index ee03245b9a0..7845e9aef66 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchClientSpy.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchClientSpy.java @@ -23,38 +23,38 @@ import org.hibernate.search.engine.environment.bean.BeanReference; import org.hibernate.search.engine.environment.bean.BeanResolver; import org.hibernate.search.engine.environment.thread.spi.ThreadProvider; -import org.hibernate.search.util.impl.integrationtest.common.rule.CallQueue; +import org.hibernate.search.util.impl.integrationtest.common.extension.CallQueue; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; -public class ElasticsearchClientSpy implements TestRule { +public class ElasticsearchClientSpy implements BeforeEachCallback, AfterEachCallback { private final AtomicInteger createdClientCount = new AtomicInteger(); private final AtomicInteger requestCount = new AtomicInteger(); - private final CallQueue expectations = new CallQueue<>( new CallQueue.Settings() { - @Override - public boolean allowDuplicates() { - return false; - } - } ); + private final CallQueue expectations = new CallQueue<>( () -> false ); + + private ElasticsearchClientSpy() { + } + + public static ElasticsearchClientSpy create() { + return new ElasticsearchClientSpy(); + } @Override - public Statement apply(Statement base, Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - setup(); - try { - base.evaluate(); - verifyExpectationsMet(); - } - finally { - resetExpectations(); - tearDown(); - } - } - }; + public void beforeEach(ExtensionContext context) { + setup(); + } + + @Override + public void afterEach(ExtensionContext context) { + try { + verifyExpectationsMet(); + } + finally { + resetExpectations(); + tearDown(); + } } private void setup() { diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchClientSubmitCall.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchClientSubmitCall.java index 63785b27a2d..8a2bfe53702 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchClientSubmitCall.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchClientSubmitCall.java @@ -12,7 +12,7 @@ import java.util.List; import org.hibernate.search.backend.elasticsearch.client.spi.ElasticsearchRequest; -import org.hibernate.search.util.impl.integrationtest.common.rule.Call; +import org.hibernate.search.util.impl.integrationtest.common.extension.Call; import com.google.gson.Gson; import com.google.gson.JsonArray; diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendAccessor.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendAccessor.java index f6301418cf2..2aaf152efd8 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendAccessor.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendAccessor.java @@ -10,7 +10,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendAccessor; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexSettingsTestUtils; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; public class ElasticsearchTckBackendAccessor implements TckBackendAccessor { private final TestElasticsearchClient client; diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendHelper.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendHelper.java index b8af2f35784..9f046a42a41 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendHelper.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendHelper.java @@ -17,7 +17,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendFeatures; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; public class ElasticsearchTckBackendHelper implements TckBackendHelper { diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendSetupStrategy.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendSetupStrategy.java index 9aa4287e2fc..0d4aa120ce7 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendSetupStrategy.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/testsupport/util/ElasticsearchTckBackendSetupStrategy.java @@ -11,7 +11,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendAccessor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchBackendConfiguration; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; class ElasticsearchTckBackendSetupStrategy extends TckBackendSetupStrategy { @@ -23,7 +23,7 @@ class ElasticsearchTckBackendSetupStrategy extends TckBackendSetupStrategyAdapt the classpath filter as needed to run a single test or an entire test package. + *

Adapt the classpath filter as needed to run a single test or an entire test package. * *

Running such tests from the IDE will require having an Elasticsearch * node running. You can easily start one by running 'mvn elasticsearch:runforked -Des.setAwait=true' @@ -20,10 +22,11 @@ * * @author Gunnar Morling */ -@RunWith(ClasspathSuite.class) -@ClasspathSuite.ClassnameFilters({ - "!.*\\$.*", // Exclude nested tests, typically used with NestedRunner - ".*\\.tck\\..*" -}) +@Suite +@SuiteDisplayName("Lucene TCK tests Runner") +// Defines a "root" package, subpackages are included. Use Include/Exclude ClassNamePatterns annotations to limit the executed tests: +@SelectPackages("org.hibernate.search.integrationtest.backend.tck") +// Default class pattern does not include IT tests, hence we want to customize it a bit: +@IncludeClassNamePatterns({ ".*Test", ".*IT" }) public class ElasticsearchTckTestRunner { } diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchBackendWorkExecutorProviderIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchBackendWorkExecutorProviderIT.java index 84c84930d22..4be5b4919dc 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchBackendWorkExecutorProviderIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchBackendWorkExecutorProviderIT.java @@ -17,32 +17,32 @@ import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.common.execution.spi.DelegatingSimpleScheduledExecutor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class ElasticsearchBackendWorkExecutorProviderIT { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class ElasticsearchBackendWorkExecutorProviderIT { @Mock private ElasticsearchWorkExecutorProvider backendWorkExecutorProvider; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); @Test - public void test() { + void test() { when( backendWorkExecutorProvider.workExecutor( any() ) ).thenReturn( new DelegatingSimpleScheduledExecutor( new ScheduledThreadPoolExecutor( 1 ), true ) ); diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchIndexingIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchIndexingIT.java index 9c792e35e54..d86ee342004 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchIndexingIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchIndexingIT.java @@ -10,6 +10,9 @@ import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchIndexMetadataTestUtils.encodeName; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.referenceProvider; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; import org.hibernate.search.backend.elasticsearch.cfg.impl.ElasticsearchBackendImplSettings; import org.hibernate.search.backend.elasticsearch.client.impl.Paths; @@ -22,15 +25,14 @@ import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.configuration.StubSingleIndexLayoutStrategy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchClientSpy; import org.hibernate.search.integrationtest.backend.elasticsearch.testsupport.util.ElasticsearchRequestAssertionMode; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -38,38 +40,27 @@ /** * Test the content of generated Elasticsearch indexing requests. */ -@RunWith(Parameterized.class) -public class ElasticsearchIndexingIT { +class ElasticsearchIndexingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Parameterized.Parameters(name = "IndexLayoutStrategy = {0}") - public static Object[][] configurations() { - return new Object[][] { - { null, defaultWriteAlias( index.name() ) }, - { "no-alias", encodeName( index.name() ) }, - { new StubSingleIndexLayoutStrategy( "custom-write", "custom-read" ), encodeName( "custom-write" ) } - }; + public static List params() { + return Arrays.asList( + Arguments.of( null, defaultWriteAlias( index.name() ) ), + Arguments.of( "no-alias", encodeName( index.name() ) ), + Arguments.of( new StubSingleIndexLayoutStrategy( "custom-write", "custom-read" ), encodeName( "custom-write" ) ) + ); } private final ElasticsearchTestDialect dialect = ElasticsearchTestDialect.get(); - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); - - @Rule - public ElasticsearchClientSpy clientSpy = new ElasticsearchClientSpy(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - private final Object layoutStrategy; - private final URLEncodedString writeName; - - public ElasticsearchIndexingIT(Object layoutStrategy, URLEncodedString writeName) { - this.layoutStrategy = layoutStrategy; - this.writeName = writeName; - } + @RegisterExtension + public ElasticsearchClientSpy clientSpy = ElasticsearchClientSpy.create(); - @Before - public void setup() { + public void init(Object layoutStrategy, URLEncodedString writeName) { setupHelper.start() .withBackendProperty( ElasticsearchBackendImplSettings.CLIENT_FACTORY, clientSpy.factoryReference() @@ -81,8 +72,10 @@ public void setup() { .setup(); } - @Test - public void addUpdateDelete_noRouting() { + @ParameterizedTest(name = "IndexLayoutStrategy = {0}") + @MethodSource("params") + void addUpdateDelete_noRouting(Object layoutStrategy, URLEncodedString writeName) { + init( layoutStrategy, writeName ); Gson gson = new Gson(); IndexIndexingPlan plan = index.createIndexingPlan(); @@ -127,8 +120,10 @@ public void addUpdateDelete_noRouting() { clientSpy.verifyExpectationsMet(); } - @Test - public void addUpdateDelete_routing() { + @ParameterizedTest(name = "IndexLayoutStrategy = {0}") + @MethodSource("params") + void addUpdateDelete_routing(Object layoutStrategy, URLEncodedString writeName) { + init( layoutStrategy, writeName ); Gson gson = new Gson(); String routingKey = "someRoutingKey"; diff --git a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchZeroDowntimeReindexingIT.java b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchZeroDowntimeReindexingIT.java index 7bcf390c7a5..6e055a12b2b 100644 --- a/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchZeroDowntimeReindexingIT.java +++ b/integrationtest/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/backend/elasticsearch/work/ElasticsearchZeroDowntimeReindexingIT.java @@ -23,37 +23,37 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexer; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.rule.TestElasticsearchClient; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.extension.TestElasticsearchClient; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Demonstrates the feasibility of zero-downtime reindexing, * i.e. reindexing without emptying the index, so that searches still return results while reindexing. */ @TestForIssue(jiraKey = "HSEARCH-3791") -public class ElasticsearchZeroDowntimeReindexingIT { +class ElasticsearchZeroDowntimeReindexingIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public TestElasticsearchClient elasticsearchClient = new TestElasticsearchClient(); + @RegisterExtension + public TestElasticsearchClient elasticsearchClient = TestElasticsearchClient.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void test() { + void test() { IndexIndexer indexer = index.createIndexer(); indexer.add( diff --git a/integrationtest/backend/lucene/pom.xml b/integrationtest/backend/lucene/pom.xml index e05b425ff24..bf975ba284c 100644 --- a/integrationtest/backend/lucene/pom.xml +++ b/integrationtest/backend/lucene/pom.xml @@ -33,11 +33,6 @@ hibernate-search-integrationtest-backend-tck test - - io.takari.junit - takari-cpsuite - test - diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneBackendIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneBackendIT.java index 4f807c176c9..8b4c4a604e0 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneBackendIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneBackendIT.java @@ -13,28 +13,28 @@ import org.hibernate.search.backend.lucene.analysis.impl.TokenizerChain; import org.hibernate.search.engine.common.spi.SearchIntegration; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.analysis.standard.StandardAnalyzer; -public class LuceneBackendIT { +class LuceneBackendIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final StubMappedIndex index = StubMappedIndex.withoutFields(); private static LuceneBackend backend; - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { SearchIntegration integration = setupHelper.start().withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.NONE ) .setup().integration(); @@ -43,7 +43,7 @@ public static void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void analyzer() { + void analyzer() { assertThat( backend.analyzer( DefaultAnalysisDefinitions.ANALYZER_STANDARD_ENGLISH.name ) ) .isNotEmpty() .containsInstanceOf( StandardAnalyzer.class ); @@ -54,7 +54,7 @@ public void analyzer() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void analyzer_missing() { + void analyzer_missing() { assertThat( backend.analyzer( "unknown" ) ).isEmpty(); // Normalizers are not analyzers assertThat( backend.analyzer( DefaultAnalysisDefinitions.NORMALIZER_LOWERCASE.name ) ).isEmpty(); @@ -62,7 +62,7 @@ public void analyzer_missing() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void normalizer() { + void normalizer() { assertThat( backend.normalizer( DefaultAnalysisDefinitions.NORMALIZER_LOWERCASE.name ) ) .isNotEmpty() .containsInstanceOf( HibernateSearchNormalizerWrapper.class ); @@ -70,7 +70,7 @@ public void normalizer() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void normalizer_missing() { + void normalizer_missing() { assertThat( backend.normalizer( "unknown" ) ).isEmpty(); // Analyzers are not normalizers assertThat( backend.normalizer( DefaultAnalysisDefinitions.ANALYZER_STANDARD_ENGLISH.name ) ).isEmpty(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneDocumentModelDslIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneDocumentModelDslIT.java index 1700a641c18..78edf53ca44 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneDocumentModelDslIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneDocumentModelDslIT.java @@ -12,23 +12,23 @@ import org.hibernate.search.engine.mapper.mapping.building.spi.IndexBindingContext; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class LuceneDocumentModelDslIT { +class LuceneDocumentModelDslIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private StubMappedIndex index; @Test - public void unknownAnalyzer() { + void unknownAnalyzer() { assertThatThrownBy( () -> setup( ctx -> { ctx.createTypeFactory().asString() @@ -44,7 +44,7 @@ public void unknownAnalyzer() { } @Test - public void unknownNormalizer() { + void unknownNormalizer() { assertThatThrownBy( () -> setup( ctx -> { ctx.createTypeFactory().asString() @@ -60,7 +60,7 @@ public void unknownNormalizer() { } @Test - public void unknownSearchAnalyzer() { + void unknownSearchAnalyzer() { assertThatThrownBy( () -> setup( ctx -> { ctx.createTypeFactory().asString() diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneExtensionIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneExtensionIT.java index 24b4442bab7..16f48c70989 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneExtensionIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/LuceneExtensionIT.java @@ -58,7 +58,7 @@ import org.hibernate.search.engine.search.sort.SearchSort; import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; @@ -66,9 +66,9 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.document.Document; import org.apache.lucene.document.DoublePoint; @@ -90,7 +90,7 @@ import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TopDocs; -public class LuceneExtensionIT { +class LuceneExtensionIT { private static final String FIRST_ID = "1"; private static final String SECOND_ID = "2"; @@ -98,16 +98,16 @@ public class LuceneExtensionIT { private static final String FOURTH_ID = "4"; private static final String FIFTH_ID = "5"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); private final SimpleMappedIndex otherIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "other" ); private SearchIntegration integration; - @Before - public void setup() { + @BeforeEach + void setup() { this.integration = setupHelper.start().withIndexes( mainIndex, otherIndex ).setup().integration(); initData(); @@ -115,7 +115,7 @@ public void setup() { @Test @SuppressWarnings("unused") - public void queryContext() { + void queryContext() { StubMappingScope scope = mainIndex.createScope(); // Put intermediary contexts into variables to check they have the right type @@ -158,7 +158,7 @@ public void queryContext() { } @Test - public void query() { + void query() { StubMappingScope scope = mainIndex.createScope(); SearchQuery genericQuery = scope.query() @@ -181,7 +181,7 @@ public void query() { } @Test - public void query_topDocs() { + void query_topDocs() { StubMappingScope scope = mainIndex.createScope(); LuceneSearchResult result = scope.query().extension( LuceneExtension.get() ) @@ -192,7 +192,7 @@ public void query_topDocs() { } @Test - public void query_explain_singleIndex() { + void query_explain_singleIndex() { StubMappingScope scope = mainIndex.createScope(); LuceneSearchQuery query = scope.query().extension( LuceneExtension.get() ) @@ -211,7 +211,7 @@ public void query_explain_singleIndex() { } @Test - public void query_explain_singleIndex_invalidId() { + void query_explain_singleIndex_invalidId() { StubMappingScope scope = mainIndex.createScope(); LuceneSearchQuery query = scope.query().extension( LuceneExtension.get() ) @@ -228,7 +228,7 @@ public void query_explain_singleIndex_invalidId() { } @Test - public void query_explain_multipleIndexes() { + void query_explain_multipleIndexes() { StubMappingScope scope = mainIndex.createScope( otherIndex ); LuceneSearchQuery query = scope.query().extension( LuceneExtension.get() ) @@ -247,7 +247,7 @@ public void query_explain_multipleIndexes() { } @Test - public void query_explain_multipleIndexes_missingTypeName() { + void query_explain_multipleIndexes_missingTypeName() { StubMappingScope scope = mainIndex.createScope( otherIndex ); LuceneSearchQuery query = scope.query().extension( LuceneExtension.get() ) @@ -263,7 +263,7 @@ public void query_explain_multipleIndexes_missingTypeName() { } @Test - public void query_explain_multipleIndexes_invalidIndexName() { + void query_explain_multipleIndexes_invalidIndexName() { StubMappingScope scope = mainIndex.createScope( otherIndex ); LuceneSearchQuery query = scope.query().extension( LuceneExtension.get() ) @@ -281,7 +281,7 @@ public void query_explain_multipleIndexes_invalidIndexName() { @Test @TestForIssue(jiraKey = "HSEARCH-3974") - public void scroll_onFetchable() { + void scroll_onFetchable() { // Check the scroll has the extended type and works correctly try ( LuceneSearchScroll scroll = mainIndex.query() .extension( LuceneExtension.get() ) // Call extension() on the DSL step @@ -301,7 +301,7 @@ public void scroll_onFetchable() { @Test @TestForIssue(jiraKey = "HSEARCH-3974") - public void scroll_onQuery() { + void scroll_onQuery() { // Check the scroll has the extended type and works correctly try ( LuceneSearchScroll scroll = mainIndex.query() .where( f -> f.matchAll() ) @@ -321,7 +321,7 @@ public void scroll_onQuery() { } @Test - public void predicate_fromLuceneQuery() { + void predicate_fromLuceneQuery() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -340,7 +340,7 @@ public void predicate_fromLuceneQuery() { } @Test - public void predicate_fromLuceneQuery_separatePredicate() { + void predicate_fromLuceneQuery_separatePredicate() { StubMappingScope scope = mainIndex.createScope(); SearchPredicate predicate1 = scope.predicate().extension( LuceneExtension.get() ) @@ -365,7 +365,7 @@ public void predicate_fromLuceneQuery_separatePredicate() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void predicate_fromLuceneQuery_withRoot() { + void predicate_fromLuceneQuery_withRoot() { SearchQuery query = mainIndex.query() .where( f -> { LuceneSearchPredicateFactory f2 = f.extension( LuceneExtension.get() ).withRoot( "flattenedObject" ); @@ -380,7 +380,7 @@ public void predicate_fromLuceneQuery_withRoot() { } @Test - public void sort_fromLuceneSortField() { + void sort_fromLuceneSortField() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -421,7 +421,7 @@ public void sort_fromLuceneSortField() { } @Test - public void sort_fromLuceneSortField_separateSort() { + void sort_fromLuceneSortField_separateSort() { StubMappingScope scope = mainIndex.createScope(); SearchSort sort1 = scope.sort().extension() @@ -468,7 +468,7 @@ public void sort_fromLuceneSortField_separateSort() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void sort_fromLuceneSortField_withRoot() { + void sort_fromLuceneSortField_withRoot() { assertThatQuery( mainIndex.query() .where( f -> f.matchAll() ) .sort( f -> { @@ -489,7 +489,7 @@ public void sort_fromLuceneSortField_withRoot() { } @Test - public void sort_filter_fromLuceneQuery() { + void sort_filter_fromLuceneQuery() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -527,7 +527,7 @@ public void sort_filter_fromLuceneQuery() { } @Test - public void predicate_nativeField() { + void predicate_nativeField() { StubMappingScope scope = mainIndex.createScope(); String fieldPath = "nativeField"; @@ -549,7 +549,7 @@ public void predicate_nativeField() { } @Test - public void predicate_nativeField_fromLuceneQuery() { + void predicate_nativeField_fromLuceneQuery() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -563,7 +563,7 @@ public void predicate_nativeField_fromLuceneQuery() { } @Test - public void predicate_nativeField_exists() { + void predicate_nativeField_exists() { StubMappingScope scope = mainIndex.createScope(); String fieldPath = "nativeField"; @@ -583,7 +583,7 @@ public void predicate_nativeField_exists() { } @Test - public void sort_nativeField() { + void sort_nativeField() { StubMappingScope scope = mainIndex.createScope(); String fieldPath = "nativeField"; @@ -603,7 +603,7 @@ public void sort_nativeField() { } @Test - public void sort_nativeField_fromLuceneSortField() { + void sort_nativeField_fromLuceneSortField() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -617,7 +617,7 @@ public void sort_nativeField_fromLuceneSortField() { } @Test - public void projection_nativeField() { + void projection_nativeField() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -630,7 +630,7 @@ public void projection_nativeField() { @Test @SuppressWarnings("rawtypes") - public void projection_nativeField_withProjectionConverters_enabled() { + void projection_nativeField_withProjectionConverters_enabled() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -642,7 +642,7 @@ public void projection_nativeField_withProjectionConverters_enabled() { } @Test - public void projection_nativeField_withProjectionConverters_disabled() { + void projection_nativeField_withProjectionConverters_disabled() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -654,7 +654,7 @@ public void projection_nativeField_withProjectionConverters_disabled() { } @Test - public void projection_nativeField_unsupportedProjection() { + void projection_nativeField_unsupportedProjection() { StubMappingScope scope = mainIndex.createScope(); String fieldPath = "nativeField_unsupportedProjection"; @@ -683,7 +683,7 @@ public void projection_nativeField_unsupportedProjection() { } @Test - public void projection_document() { + void projection_document() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -738,7 +738,7 @@ public void projection_document() { * even if there is a field projection, which would usually trigger document filtering. */ @Test - public void projection_documentAndField() { + void projection_documentAndField() { StubMappingScope scope = mainIndex.createScope(); SearchQuery> query = scope.query() @@ -766,7 +766,7 @@ public void projection_documentAndField() { } @Test - public void projection_explanation() { + void projection_explanation() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -783,7 +783,7 @@ public void projection_explanation() { } @Test - public void aggregation_filter_fromLuceneQuery() { + void aggregation_filter_fromLuceneQuery() { StubMappingScope scope = mainIndex.createScope(); AggregationKey> aggregationKey = AggregationKey.of( "agg" ); @@ -810,7 +810,7 @@ public void aggregation_filter_fromLuceneQuery() { } @Test - public void nativeField_invalidFieldPath() { + void nativeField_invalidFieldPath() { assertThatThrownBy( () -> mainIndex .index( FIRST_ID, document -> document.addValue( mainIndex.binding().nativeField_invalidFieldPath, 45 ) ) ) @@ -820,14 +820,14 @@ public void nativeField_invalidFieldPath() { } @Test - public void backend_unwrap() { + void backend_unwrap() { Backend backend = integration.backend(); assertThat( backend.unwrap( LuceneBackend.class ) ) .isNotNull(); } @Test - public void backend_unwrap_error_unknownType() { + void backend_unwrap_error_unknownType() { Backend backend = integration.backend(); assertThatThrownBy( () -> backend.unwrap( String.class ) ) @@ -839,14 +839,14 @@ public void backend_unwrap_error_unknownType() { } @Test - public void mainIndex_unwrap() { + void mainIndex_unwrap() { IndexManager mainIndexFromIntegration = integration.indexManager( mainIndex.name() ); assertThat( mainIndexFromIntegration.unwrap( LuceneIndexManager.class ) ) .isNotNull(); } @Test - public void mainIndex_unwrap_error_unknownType() { + void mainIndex_unwrap_error_unknownType() { IndexManager mainIndexFromIntegration = integration.indexManager( mainIndex.name() ); assertThatThrownBy( () -> mainIndexFromIntegration.unwrap( String.class ) ) @@ -859,7 +859,7 @@ public void mainIndex_unwrap_error_unknownType() { } @Test - public void indexReaderAccessor() throws Exception { + void indexReaderAccessor() throws Exception { StubMappingScope scope = mainIndex.createScope(); try ( IndexReader indexReader = scope.extension( LuceneExtension.get() ).openIndexReader() ) { @@ -878,7 +878,7 @@ public void indexReaderAccessor() throws Exception { } @Test - public void documentProjectionInsideNested() { + void documentProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( LuceneExtension.get() ).document() @@ -894,7 +894,7 @@ public void documentProjectionInsideNested() { } @Test - public void explanationProjectionInsideNested() { + void explanationProjectionInsideNested() { assertThatThrownBy( () -> mainIndex.createScope().query() .select( f -> f.object( "nestedObject" ).from( f.extension( LuceneExtension.get() ).explanation() diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/analysis/LuceneAnalysisConfigurerIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/analysis/LuceneAnalysisConfigurerIT.java index 8771c982622..c4ffd263f06 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/analysis/LuceneAnalysisConfigurerIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/analysis/LuceneAnalysisConfigurerIT.java @@ -18,15 +18,15 @@ import org.hibernate.search.backend.lucene.analysis.LuceneAnalysisConfigurationContext; import org.hibernate.search.backend.lucene.analysis.LuceneAnalysisConfigurer; import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.backend.lucene.LuceneAnalysisUtils; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.charfilter.HTMLStripCharFilterFactory; @@ -34,16 +34,16 @@ import org.apache.lucene.analysis.core.WhitespaceTokenizerFactory; import org.apache.lucene.analysis.pattern.PatternTokenizerFactory; -public class LuceneAnalysisConfigurerIT { +class LuceneAnalysisConfigurerIT { private static final String ANALYSIS_CONFIGURER_ERROR_MESSAGE_PREFIX = "Unable to apply analysis configuration"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); @Test @TestForIssue(jiraKey = "HSEARCH-4404") - public void availableComponents() { + void availableComponents() { assertThat( CollectingConfigurer.TOKENIZERS ).isEmpty(); assertThat( CollectingConfigurer.CHAR_FILTERS ).isEmpty(); assertThat( CollectingConfigurer.TOKEN_FILTERS ).isEmpty(); @@ -70,7 +70,7 @@ public void configure(LuceneAnalysisConfigurationContext context) { @Test @TestForIssue(jiraKey = "HSEARCH-4404") - public void byName() throws IOException { + void byName() throws IOException { LuceneBackend backend = setup( ByNameConfigurer.class.getName() ); Optional analyzer = backend.analyzer( "analyzer" ); @@ -99,7 +99,7 @@ public void configure(LuceneAnalysisConfigurationContext context) { } @Test - public void byClass() throws IOException { + void byClass() throws IOException { LuceneBackend backend = setup( ByClassConfigurer.class.getName() ); Optional analyzer = backend.analyzer( "analyzer" ); @@ -128,7 +128,7 @@ public void configure(LuceneAnalysisConfigurationContext context) { } @Test - public void error_invalidReference() { + void error_invalidReference() { assertThatThrownBy( () -> setup( "foobar" ) ) @@ -145,7 +145,7 @@ public void error_invalidReference() { } @Test - public void error_failingConfigurer() { + void error_failingConfigurer() { assertThatThrownBy( () -> setup( FailingConfigurer.class.getName() ) ) @@ -175,7 +175,7 @@ private static class SimulatedFailure extends RuntimeException { } @Test - public void error_parameter_namingConflict() { + void error_parameter_namingConflict() { assertThatThrownBy( () -> setup( ParameterNamingConflictConfigurer.class.getName() ) ) @@ -204,7 +204,7 @@ public void configure(LuceneAnalysisConfigurationContext context) { @Test @TestForIssue(jiraKey = "HSEARCH-4594") - public void multipleConfigurers() { + void multipleConfigurers() { LuceneBackend backend = setup( MultipleConfigurers1.class.getName() + "," + MultipleConfigurers2.class.getName() ); assertThat( backend.analyzer( "analyzer1" ) ).isPresent(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/analysis/LuceneSimilarityIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/analysis/LuceneSimilarityIT.java index 8e86ee56bea..58c3e878bd3 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/analysis/LuceneSimilarityIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/analysis/LuceneSimilarityIT.java @@ -14,29 +14,29 @@ import org.hibernate.search.backend.lucene.index.impl.LuceneIndexManagerImpl; import org.hibernate.search.backend.lucene.index.impl.Shard; import org.hibernate.search.backend.lucene.lowlevel.index.impl.IndexAccessorImpl; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.search.similarities.BM25Similarity; import org.apache.lucene.search.similarities.ClassicSimilarity; import org.apache.lucene.search.similarities.Similarity; -public class LuceneSimilarityIT { +class LuceneSimilarityIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); @Test @TestForIssue(jiraKey = "HSEARCH-3777") - public void defaults() { + void defaults() { setup( null ); LuceneIndexManagerImpl luceneIndexManager = index.unwrapForTests( LuceneIndexManagerImpl.class ); @@ -61,7 +61,7 @@ public void defaults() { @Test @TestForIssue(jiraKey = "HSEARCH-3777") @PortedFromSearch5(original = "org.hibernate.search.test.similarity.SimilarityTest") - public void custom() { + void custom() { setup( new ClassicSimilarity() ); LuceneIndexManagerImpl luceneIndexManager = index.unwrapForTests( LuceneIndexManagerImpl.class ); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/cache/LuceneQueryCacheConfigurerIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/cache/LuceneQueryCacheConfigurerIT.java index 631a2ecc4b3..c70aed880e4 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/cache/LuceneQueryCacheConfigurerIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/cache/LuceneQueryCacheConfigurerIT.java @@ -22,12 +22,12 @@ import org.hibernate.search.engine.mapper.mapping.building.spi.IndexBindingContext; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.search.Query; import org.apache.lucene.search.QueryCache; @@ -35,15 +35,15 @@ import org.apache.lucene.search.Weight; import org.apache.lucene.util.Version; -public class LuceneQueryCacheConfigurerIT { +class LuceneQueryCacheConfigurerIT { private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); @Test - public void error_failingQueryCacheConfigurer() { + void error_failingQueryCacheConfigurer() { setup( FailingQueryCacheConfigurer.class.getName() ); initData( 10 ); @@ -68,7 +68,7 @@ public void configure(QueryCachingConfigurationContext context) { } @Test - public void error_failingQueryCachingPolicyConfigurer() { + void error_failingQueryCachingPolicyConfigurer() { setup( FailingCachePolicyExceptionQueryCacheConfigurer.class.getName() ); initData( 10 ); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/index/LuceneIndexManagerIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/index/LuceneIndexManagerIT.java index d7578be025c..5f6272e2bf2 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/index/LuceneIndexManagerIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/index/LuceneIndexManagerIT.java @@ -19,29 +19,29 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.UnsupportedOperationBehavior; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.backend.lucene.LuceneAnalysisUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.analysis.Analyzer; -public class LuceneIndexManagerIT { +class LuceneIndexManagerIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private static LuceneIndexManager indexApi; - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.NONE ) .setup(); @@ -50,7 +50,7 @@ public static void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void indexingAnalyzer() throws IOException { + void indexingAnalyzer() throws IOException { Analyzer analyzer = indexApi.indexingAnalyzer(); assertThat( LuceneAnalysisUtils.analyze( analyzer, "whitespace_lowercase", "Foo Bar" ) ) .containsExactly( "foo", "bar" ); @@ -67,7 +67,7 @@ public void indexingAnalyzer() throws IOException { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void searchAnalyzer() throws IOException { + void searchAnalyzer() throws IOException { Analyzer analyzer = indexApi.searchAnalyzer(); assertThat( LuceneAnalysisUtils.analyze( analyzer, "whitespace_lowercase", "Foo Bar" ) ) .containsExactly( "foo", "bar" ); @@ -84,7 +84,7 @@ public void searchAnalyzer() throws IOException { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void computeSizeInBytes() { + void computeSizeInBytes() { long initialSize = indexApi.computeSizeInBytes(); assertThat( initialSize ).isGreaterThanOrEqualTo( 0L ); @@ -105,7 +105,7 @@ public void computeSizeInBytes() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void computeSizeInBytesAsync() { + void computeSizeInBytesAsync() { CompletableFuture initialSizeFuture = indexApi.computeSizeInBytesAsync().toCompletableFuture(); await().untilAsserted( () -> assertThat( initialSizeFuture ).isCompleted() ); long initialSize = initialSizeFuture.join(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/index/LuceneIndexRestartFromPreviousIntegrationIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/index/LuceneIndexRestartFromPreviousIntegrationIT.java index f3609daba9d..165396530b0 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/index/LuceneIndexRestartFromPreviousIntegrationIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/index/LuceneIndexRestartFromPreviousIntegrationIT.java @@ -14,36 +14,32 @@ import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class LuceneIndexRestartFromPreviousIntegrationIT { +class LuceneIndexRestartFromPreviousIntegrationIT { - @Parameterized.Parameters(name = "{0}") - public static List params() { - return Arrays.asList( "local-heap", "local-filesystem" ); + public static List params() { + return Arrays.asList( Arguments.of( "local-heap" ), Arguments.of( "local-filesystem" ) ); } - @Parameterized.Parameter - public String directoryType; - - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex indexV1 = SimpleMappedIndex.of( IndexBindingV1::new ); private final SimpleMappedIndex indexV2 = SimpleMappedIndex.of( IndexBindingV2::new ); - @Test - public void addNewFieldOnExistingIndex() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addNewFieldOnExistingIndex(String directoryType) { StubMapping mappingV1 = setupHelper.start() .withSchemaManagement( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY ) .withIndex( indexV1 ) diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lifecycle/LuceneCleanupIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lifecycle/LuceneCleanupIT.java index c90db15192f..ed67604c065 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lifecycle/LuceneCleanupIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lifecycle/LuceneCleanupIT.java @@ -9,6 +9,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.referenceProvider; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.backend.lucene.lowlevel.directory.spi.DirectoryProvider; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; @@ -27,51 +30,42 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.IntegerFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.backend.lucene.directory.OpenResourceTracker; import org.hibernate.search.util.impl.integrationtest.backend.lucene.directory.TrackingDirectoryProvider; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test that the Lucene backend correctly releases open resources. */ -@RunWith(Parameterized.class) -public class LuceneCleanupIT { - - @Parameterized.Parameters(name = "commit_interval {0}, refresh_interval {0}") - public static Object[][] strategies() { - return new Object[][] { - { null, null }, - { 0, 0 }, - { 0, 1_000 }, - { 1_000, 0 }, - { 1_000, 1_000 } - }; +class LuceneCleanupIT { + + public static List params() { + return Arrays.asList( + Arguments.of( null, null ), + Arguments.of( 0, 0 ), + Arguments.of( 0, 1_000 ), + Arguments.of( 1_000, 0 ), + Arguments.of( 1_000, 1_000 ) + ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); - - private final Integer commitInterval; - private final Integer refreshInterval; + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - public LuceneCleanupIT(Integer commitInterval, Integer refreshInterval) { - this.commitInterval = commitInterval; - this.refreshInterval = refreshInterval; - } - - @Test - public void test() { + @ParameterizedTest(name = "commit_interval {0}, refresh_interval {0}") + @MethodSource("params") + void test(Integer commitInterval, Integer refreshInterval) { OpenResourceTracker tracker = new OpenResourceTracker(); - StubMapping mapping = setup( tracker ); + StubMapping mapping = setup( tracker, commitInterval, refreshInterval ); // Execute a few operations to be sure that we open files doQuery(); @@ -124,7 +118,7 @@ private void doStore(int... ids) { plan.execute( OperationSubmitter.blocking() ).join(); } - private StubMapping setup(OpenResourceTracker tracker) { + private StubMapping setup(OpenResourceTracker tracker, Integer commitInterval, Integer refreshInterval) { return setupHelper.start() .withIndex( index ) .withBackendProperty( LuceneIndexSettings.IO_COMMIT_INTERVAL, commitInterval ) diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/AbstractBuiltInDirectoryIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/AbstractBuiltInDirectoryIT.java index 948ce8c9369..f73e23f156b 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/AbstractBuiltInDirectoryIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/AbstractBuiltInDirectoryIT.java @@ -16,17 +16,17 @@ import org.hibernate.search.backend.lucene.index.impl.LuceneIndexManagerImpl; import org.hibernate.search.backend.lucene.index.impl.Shard; import org.hibernate.search.backend.lucene.lowlevel.index.impl.IndexAccessorImpl; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.apache.lucene.store.Lock; -public abstract class AbstractBuiltInDirectoryIT extends AbstractDirectoryIT { +abstract class AbstractBuiltInDirectoryIT extends AbstractDirectoryIT { protected static final String SINGLE_INSTANCE_LOCK_FQN = "org.apache.lucene.store.SingleInstanceLockFactory$SingleInstanceLock"; @@ -38,7 +38,7 @@ public abstract class AbstractBuiltInDirectoryIT extends AbstractDirectoryIT { @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5( original = "org.hibernate.search.test.directoryProvider.CustomLockProviderTest.testUseOfNativeLockingFactory") - public void lockingStrategy_default() { + void lockingStrategy_default() { testValidLockingStrategy( null, getDefaultLockClassName() ); } @@ -46,7 +46,7 @@ public void lockingStrategy_default() { @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5( original = "org.hibernate.search.test.directoryProvider.CustomLockProviderTest.testUseOfSimpleLockingFactory") - public void lockingStrategy_simpleFilesystem() { + void lockingStrategy_simpleFilesystem() { if ( isFSDirectory() ) { testValidLockingStrategy( "simple-filesystem", SIMPLE_FS_LOCK_FQN ); } @@ -59,7 +59,7 @@ public void lockingStrategy_simpleFilesystem() { @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5( original = "org.hibernate.search.test.directoryProvider.CustomLockProviderTest.testUseOfNativeLockingFactory") - public void lockingStrategy_nativeFilesystem() { + void lockingStrategy_nativeFilesystem() { if ( isFSDirectory() ) { testValidLockingStrategy( "native-filesystem", NATIVE_FS_LOCK_FQN ); } @@ -72,13 +72,13 @@ public void lockingStrategy_nativeFilesystem() { @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5( original = "org.hibernate.search.test.directoryProvider.CustomLockProviderTest.testUseOfSingleLockingFactory") - public void lockingStrategy_singleInstance() { + void lockingStrategy_singleInstance() { testValidLockingStrategy( "single-instance", SINGLE_INSTANCE_LOCK_FQN ); } @Test @TestForIssue(jiraKey = "HSEARCH-3440") - public void lockingStrategy_none() { + void lockingStrategy_none() { testValidLockingStrategy( "none", NO_LOCK_FQN ); } @@ -86,7 +86,7 @@ public void lockingStrategy_none() { @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5( original = "org.hibernate.search.test.directoryProvider.CustomLockProviderTest.testFailOnNonExistentLockingFactory") - public void lockingStrategy_invalid() { + void lockingStrategy_invalid() { assertThatThrownBy( () -> setup( c -> c.withBackendProperty( LuceneIndexSettings.DIRECTORY_LOCKING_STRATEGY, "some_invalid_name" diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/AbstractDirectoryIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/AbstractDirectoryIT.java index e8da6ec5fb2..011696d4a12 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/AbstractDirectoryIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/AbstractDirectoryIT.java @@ -18,13 +18,12 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Rule; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.extension.RegisterExtension; public abstract class AbstractDirectoryIT { @@ -32,11 +31,8 @@ public abstract class AbstractDirectoryIT { private static final String DOCUMENT_2 = "2"; private static final String DOCUMENT_3 = "3"; - @Rule - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); - - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); protected static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/CustomDirectoryIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/CustomDirectoryIT.java index f54c881df65..ca648ec7a20 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/CustomDirectoryIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/CustomDirectoryIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.Directory; -public class CustomDirectoryIT extends AbstractDirectoryIT { +class CustomDirectoryIT extends AbstractDirectoryIT { - @Rule - public StaticCounters staticCounters = new StaticCounters(); + @RegisterExtension + public StaticCounters staticCounters = StaticCounters.create(); @Test @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5(original = "org.hibernate.search.test.directoryProvider.DirectoryLifecycleTest.testLifecycle") - public void valid() { + void valid() { setup( CustomDirectoryProvider.class, c -> c.expectCustomBeans() .withBackendProperty( "directory." + CustomDirectoryProvider.CONFIGURATION_PROPERTY_KEY_RADICAL, CustomDirectoryProvider.CONFIGURATION_PROPERTY_EXPECTED_VALUE ) ); @@ -58,7 +58,7 @@ public void valid() { @Test @TestForIssue(jiraKey = "HSEARCH-3440") - public void invalid() { + void invalid() { String invalidDirectoryType = "someInvalidDirectoryType"; assertThatThrownBy( () -> setup( "someInvalidDirectoryType", c -> c.expectCustomBeans() ) ) .isInstanceOf( SearchException.class ) diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneDirectorySettingsPerShardIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneDirectorySettingsPerShardIT.java index aad5872fd9d..cd9feb8d8db 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneDirectorySettingsPerShardIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneDirectorySettingsPerShardIT.java @@ -10,33 +10,40 @@ import java.nio.file.Path; import java.util.List; +import java.util.function.Function; import org.hibernate.search.backend.lucene.index.impl.LuceneIndexManagerImpl; import org.hibernate.search.backend.lucene.index.impl.Shard; import org.hibernate.search.backend.lucene.lowlevel.index.impl.IndexAccessorImpl; import org.hibernate.search.integrationtest.backend.lucene.sharding.AbstractSettingsPerShardIT; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.FSDirectory; @TestForIssue(jiraKey = "HSEARCH-3636") -public class LuceneDirectorySettingsPerShardIT extends AbstractSettingsPerShardIT { +class LuceneDirectorySettingsPerShardIT extends AbstractSettingsPerShardIT { - public LuceneDirectorySettingsPerShardIT(String ignoredLabel, SearchSetupHelper setupHelper, List shardIds) { - super( ignoredLabel, setupHelper, shardIds ); - } + @TempDir + public Path temporaryFolder; + + @TempDir + public Path anotherTemporaryFolder; - @Test - public void test() { - Path root1Directory = temporaryFolder.getRoot().toPath(); - Path shard0Directory = root1Directory.resolve( index.name() ).resolve( shardIds.get( 0 ) ); - Path shard1Directory = root1Directory.resolve( index.name() ).resolve( shardIds.get( 1 ) ); - Path root2Directory = temporaryFolder.getRoot().toPath(); - Path shard2Directory = root2Directory.resolve( index.name() ).resolve( shardIds.get( 2 ) ); + @ParameterizedTest(name = "{0} - {2}") + @MethodSource("params") + void test(String ignoredLabel, Function> setupStrategyFunction, + List shardIds) { + init( ignoredLabel, setupStrategyFunction, shardIds ); + Path shard0Directory = temporaryFolder.resolve( index.name() ).resolve( shardIds.get( 0 ) ); + Path shard1Directory = temporaryFolder.resolve( index.name() ).resolve( shardIds.get( 1 ) ); + Path shard2Directory = anotherTemporaryFolder.resolve( index.name() ).resolve( shardIds.get( 2 ) ); assertThat( shard0Directory ).doesNotExist(); assertThat( shard1Directory ).doesNotExist(); @@ -44,8 +51,9 @@ public void test() { setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), "directory.type", "local-filesystem" ) - .withIndexProperty( index.name(), "directory.root", root1Directory.toString() ) - .withIndexProperty( index.name(), "shards." + shardIds.get( 2 ) + ".directory.root", root2Directory.toString() ) + .withIndexProperty( index.name(), "directory.root", temporaryFolder.toAbsolutePath().toString() ) + .withIndexProperty( index.name(), "shards." + shardIds.get( 2 ) + ".directory.root", + anotherTemporaryFolder.toAbsolutePath().toString() ) .withIndexProperty( index.name(), "shards." + shardIds.get( 3 ) + ".directory.type", "local-heap" ) .setup(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneLocalFileSystemDirectoryIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneLocalFileSystemDirectoryIT.java index a35382a26d5..13133e39004 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneLocalFileSystemDirectoryIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneLocalFileSystemDirectoryIT.java @@ -21,10 +21,11 @@ import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; import org.apache.logging.log4j.Level; import org.apache.lucene.store.Directory; @@ -32,26 +33,28 @@ import org.apache.lucene.store.MMapDirectory; import org.apache.lucene.store.NIOFSDirectory; -public class LuceneLocalFileSystemDirectoryIT extends AbstractBuiltInDirectoryIT { +class LuceneLocalFileSystemDirectoryIT extends AbstractBuiltInDirectoryIT { - @Rule + @RegisterExtension public final ExpectedLog4jLog logged = ExpectedLog4jLog.create(); + @TempDir + Path temporaryFolder; + /** * Test that the index is created in the configured root. */ @Test @TestForIssue(jiraKey = "HSEARCH-3440") - public void root() throws IOException { - Path rootDirectory = temporaryFolder.getRoot().toPath(); - Path indexDirectory = rootDirectory.resolve( index.name() ); + void root() throws IOException { + Path indexDirectory = temporaryFolder.resolve( index.name() ); assertThat( indexDirectory ) .doesNotExist(); setup( c -> c.withBackendProperty( LuceneIndexSettings.DIRECTORY_ROOT, - temporaryFolder.getRoot().getAbsolutePath() + temporaryFolder.toAbsolutePath() ) ); assertThat( indexDirectory ) @@ -69,14 +72,14 @@ public void root() throws IOException { @Test @TestForIssue(jiraKey = "HSEARCH-3440") - public void filesystemAccessStrategy_default() { + void filesystemAccessStrategy_default() { // The actual class used here is OS-dependent testFileSystemAccessStrategy( null, FSDirectory.class, false ); } @Test @TestForIssue(jiraKey = "HSEARCH-3440") - public void filesystemAccessStrategy_auto() { + void filesystemAccessStrategy_auto() { // The actual class used here is OS-dependent testFileSystemAccessStrategy( "auto", FSDirectory.class, false ); } @@ -84,14 +87,14 @@ public void filesystemAccessStrategy_auto() { @Test @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5(original = "org.hibernate.search.test.directoryProvider.FSDirectorySelectionTest.testNIODirectoryType") - public void filesystemAccessStrategy_nio() { + void filesystemAccessStrategy_nio() { testFileSystemAccessStrategy( "nio", NIOFSDirectory.class, false ); } @Test @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5(original = "org.hibernate.search.test.directoryProvider.FSDirectorySelectionTest.testMMapDirectoryType") - public void filesystemAccessStrategy_mmap() { + void filesystemAccessStrategy_mmap() { testFileSystemAccessStrategy( "mmap", MMapDirectory.class, false ); } @@ -99,7 +102,7 @@ public void filesystemAccessStrategy_mmap() { @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5( original = "org.hibernate.search.test.directoryProvider.FSDirectorySelectionTest.testInvalidDirectoryType") - public void filesystemAccessStrategy_invalid() { + void filesystemAccessStrategy_invalid() { assertThatThrownBy( () -> setup( c -> c.withBackendProperty( LuceneIndexSettings.DIRECTORY_FILESYSTEM_ACCESS_STRATEGY, "some_invalid_name" diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneLocalHeapDirectoryIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneLocalHeapDirectoryIT.java index eaa49ed064d..2ba9f82eef8 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneLocalHeapDirectoryIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/LuceneLocalHeapDirectoryIT.java @@ -14,21 +14,16 @@ import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; import org.apache.lucene.store.ByteBuffersDirectory; -public class LuceneLocalHeapDirectoryIT extends AbstractBuiltInDirectoryIT { - - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); +class LuceneLocalHeapDirectoryIT extends AbstractBuiltInDirectoryIT { @Test @TestForIssue(jiraKey = "HSEARCH-3440") @PortedFromSearch5(original = "org.hibernate.search.test.directoryProvider.RamDirectoryTest.localHeap") - public void test() { + void test() { setup( c -> c ); checkIndexingAndQuerying(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/MultiDirectoryIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/MultiDirectoryIT.java index d63e549cdcc..acf41aade2b 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/MultiDirectoryIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/directory/MultiDirectoryIT.java @@ -22,26 +22,29 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; import org.apache.lucene.store.ByteBuffersDirectory; -public class MultiDirectoryIT { +class MultiDirectoryIT { private static final String DOCUMENT_1 = "1"; private static final String DOCUMENT_2 = "2"; private static final String DOCUMENT_3 = "3"; - @Rule - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); + @TempDir + public Path temporaryFolder; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @TempDir + public Path anotherTemporaryFolder; + + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); protected static final SimpleMappedIndex index1 = SimpleMappedIndex.of( IndexBinding::new ) .name( "index1" ); @@ -53,12 +56,10 @@ public class MultiDirectoryIT { .name( "index4" ); @Test - public void test() throws IOException { - Path root1Directory = temporaryFolder.getRoot().toPath(); - Path index1Directory = root1Directory.resolve( index1.name() ); - Path index2Directory = root1Directory.resolve( index2.name() ); - Path root2Directory = temporaryFolder.getRoot().toPath(); - Path index3Directory = root2Directory.resolve( index3.name() ); + void test() throws IOException { + Path index1Directory = temporaryFolder.resolve( index1.name() ); + Path index2Directory = temporaryFolder.resolve( index2.name() ); + Path index3Directory = anotherTemporaryFolder.resolve( index3.name() ); assertThat( index1Directory ).doesNotExist(); assertThat( index2Directory ).doesNotExist(); @@ -68,9 +69,10 @@ public void test() throws IOException { .withIndexes( index1, index2, index3, index4 ) // Default: FS, root 1 .withBackendProperty( LuceneIndexSettings.DIRECTORY_TYPE, "local-filesystem" ) - .withBackendProperty( LuceneIndexSettings.DIRECTORY_ROOT, root1Directory.toString() ) + .withBackendProperty( LuceneIndexSettings.DIRECTORY_ROOT, temporaryFolder.toAbsolutePath().toString() ) // Index 3: FS, root 2 - .withIndexProperty( index3.name(), LuceneIndexSettings.DIRECTORY_ROOT, root2Directory.toString() ) + .withIndexProperty( index3.name(), LuceneIndexSettings.DIRECTORY_ROOT, + anotherTemporaryFolder.toAbsolutePath().toString() ) // Index 4: heap .withIndexProperty( index4.name(), LuceneIndexSettings.DIRECTORY_TYPE, "local-heap" ) .setup(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/reader/LuceneIndexReaderRefreshBaseIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/reader/LuceneIndexReaderRefreshBaseIT.java index 7bf63ab9646..cb3c50a221a 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/reader/LuceneIndexReaderRefreshBaseIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/reader/LuceneIndexReaderRefreshBaseIT.java @@ -9,6 +9,9 @@ import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.referenceProvider; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.backend.document.IndexFieldReference; @@ -18,18 +21,17 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.awaitility.Awaitility; -@RunWith(Parameterized.class) -public class LuceneIndexReaderRefreshBaseIT { +class LuceneIndexReaderRefreshBaseIT { /* * Pick a value that is: @@ -43,34 +45,26 @@ public class LuceneIndexReaderRefreshBaseIT { * These parameters should not have any effect on the test. * They are here to check that we get the same behavior independently from these parameters. */ - @Parameterized.Parameters(name = "Commit strategy {0}, commit_interval {1}") - public static Object[][] strategies() { - return new Object[][] { - { DocumentCommitStrategy.NONE, null }, - { DocumentCommitStrategy.FORCE, null }, - { DocumentCommitStrategy.NONE, 0 }, - { DocumentCommitStrategy.FORCE, 0 }, - { DocumentCommitStrategy.NONE, NON_ZERO_DELAY }, - { DocumentCommitStrategy.FORCE, NON_ZERO_DELAY } - }; + public static List params() { + return Arrays.asList( + Arguments.of( DocumentCommitStrategy.NONE, null ), + Arguments.of( DocumentCommitStrategy.FORCE, null ), + Arguments.of( DocumentCommitStrategy.NONE, 0 ), + Arguments.of( DocumentCommitStrategy.FORCE, 0 ), + Arguments.of( DocumentCommitStrategy.NONE, NON_ZERO_DELAY ), + Arguments.of( DocumentCommitStrategy.FORCE, NON_ZERO_DELAY ) + ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - private final DocumentCommitStrategy commitStrategy; - private final Integer commitInterval; - - public LuceneIndexReaderRefreshBaseIT(DocumentCommitStrategy commitStrategy, Integer commitInterval) { - this.commitStrategy = commitStrategy; - this.commitInterval = commitInterval; - } - - @Test - public void ioStrategyDefault_refreshIntervalDefault() { - setup( null, null ); + @ParameterizedTest(name = "Commit strategy {0}, commit_interval {1}") + @MethodSource("params") + void ioStrategyDefault_refreshIntervalDefault(DocumentCommitStrategy commitStrategy, Integer commitInterval) { + setup( null, null, commitInterval ); SearchQuery query = index.createScope().query() .where( f -> f.match().field( "text" ).matching( "text1" ) ) @@ -89,9 +83,10 @@ public void ioStrategyDefault_refreshIntervalDefault() { assertThatQuery( query ).hasTotalHitCount( 1 ); } - @Test - public void ioStrategyDefault_refreshIntervalZero() { - setup( null, 0 ); + @ParameterizedTest(name = "Commit strategy {0}, commit_interval {1}") + @MethodSource("params") + void ioStrategyDefault_refreshIntervalZero(DocumentCommitStrategy commitStrategy, Integer commitInterval) { + setup( null, 0, commitInterval ); SearchQuery query = index.createScope().query() .where( f -> f.match().field( "text" ).matching( "text1" ) ) @@ -110,9 +105,11 @@ public void ioStrategyDefault_refreshIntervalZero() { assertThatQuery( query ).hasTotalHitCount( 1 ); } - @Test - public void ioStrategyDefault_refreshIntervalPositive_refreshStrategyNone() { - setup( null, NON_ZERO_DELAY ); + @ParameterizedTest(name = "Commit strategy {0}, commit_interval {1}") + @MethodSource("params") + void ioStrategyDefault_refreshIntervalPositive_refreshStrategyNone(DocumentCommitStrategy commitStrategy, + Integer commitInterval) { + setup( null, NON_ZERO_DELAY, commitInterval ); SearchQuery query = index.createScope().query() .where( f -> f.match().field( "text" ).matching( "text1" ) ) @@ -134,9 +131,11 @@ public void ioStrategyDefault_refreshIntervalPositive_refreshStrategyNone() { Awaitility.await().untilAsserted( () -> assertThatQuery( query ).hasTotalHitCount( 1 ) ); } - @Test - public void ioStrategyDefault_refreshIntervalPositive_refreshStrategyForce() { - setup( null, NON_ZERO_DELAY ); + @ParameterizedTest(name = "Commit strategy {0}, commit_interval {1}") + @MethodSource("params") + void ioStrategyDefault_refreshIntervalPositive_refreshStrategyForce(DocumentCommitStrategy commitStrategy, + Integer commitInterval) { + setup( null, NON_ZERO_DELAY, commitInterval ); SearchQuery query = index.createScope().query() .where( f -> f.match().field( "text" ).matching( "text1" ) ) @@ -155,9 +154,10 @@ public void ioStrategyDefault_refreshIntervalPositive_refreshStrategyForce() { assertThatQuery( query ).hasTotalHitCount( 1 ); } - @Test - public void ioStrategyDebug() { - setup( "debug", null ); + @ParameterizedTest(name = "Commit strategy {0}, commit_interval {1}") + @MethodSource("params") + void ioStrategyDebug(DocumentCommitStrategy commitStrategy, Integer commitInterval) { + setup( "debug", null, commitInterval ); SearchQuery query = index.createScope().query() .where( f -> f.match().field( "text" ).matching( "text1" ) ) @@ -176,7 +176,7 @@ public void ioStrategyDebug() { assertThatQuery( query ).hasTotalHitCount( 1 ); } - private void setup(String ioStrategyName, Integer refreshIntervalMs) { + private void setup(String ioStrategyName, Integer refreshIntervalMs, Integer commitInterval) { setupHelper.start() .withIndex( index ) .withBackendProperty( LuceneIndexSettings.IO_STRATEGY, ioStrategyName ) diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/reader/LuceneIndexReaderRefreshSettingsPerShardIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/reader/LuceneIndexReaderRefreshSettingsPerShardIT.java index 73574eb8462..85bc4aedf51 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/reader/LuceneIndexReaderRefreshSettingsPerShardIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/reader/LuceneIndexReaderRefreshSettingsPerShardIT.java @@ -10,6 +10,7 @@ import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.referenceProvider; import java.util.List; +import java.util.function.Function; import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.backend.work.execution.DocumentCommitStrategy; @@ -18,15 +19,17 @@ import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.lucene.sharding.AbstractSettingsPerShardIT; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.awaitility.Awaitility; @TestForIssue(jiraKey = "HSEARCH-3636") -public class LuceneIndexReaderRefreshSettingsPerShardIT extends AbstractSettingsPerShardIT { +class LuceneIndexReaderRefreshSettingsPerShardIT extends AbstractSettingsPerShardIT { /* * Pick a value that is: @@ -36,13 +39,11 @@ public class LuceneIndexReaderRefreshSettingsPerShardIT extends AbstractSettings */ private static final int NON_ZERO_DELAY = 2000; - public LuceneIndexReaderRefreshSettingsPerShardIT(String ignoredLabel, SearchSetupHelper setupHelper, + @ParameterizedTest(name = "{0} - {2}") + @MethodSource("params") + void test(String ignoredLabel, Function> setupStrategyFunction, List shardIds) { - super( ignoredLabel, setupHelper, shardIds ); - } - - @Test - public void test() { + init( ignoredLabel, setupStrategyFunction, shardIds ); setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), "io.refresh_interval", NON_ZERO_DELAY ) .withIndexProperty( index.name(), "shards." + shardIds.get( 2 ) + ".io.refresh_interval", 0 ) diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterCommitIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterCommitIT.java index 6af0dc495c0..4385d43eaf5 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterCommitIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterCommitIT.java @@ -11,6 +11,8 @@ import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.referenceProvider; import java.io.IOException; +import java.util.Arrays; +import java.util.List; import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.backend.lucene.lowlevel.common.impl.MetadataFields; @@ -19,20 +21,19 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; import org.hibernate.search.integrationtest.backend.lucene.testsupport.util.LuceneIndexContentUtils; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.awaitility.Awaitility; -@RunWith(Parameterized.class) -public class LuceneIndexWriterCommitIT { +class LuceneIndexWriterCommitIT { /* * Pick a value that is: @@ -42,35 +43,27 @@ public class LuceneIndexWriterCommitIT { */ private static final int NON_ZERO_DELAY = 1000; - @Parameterized.Parameters(name = "I/O strategy {0}, commit_interval {1}") - public static Object[][] strategies() { - return new Object[][] { - { "debug", null }, - { null, null }, - { null, 0 }, - { null, NON_ZERO_DELAY }, - { "near-real-time", null }, - { "near-real-time", 0 }, - { "near-real-time", NON_ZERO_DELAY } - }; + public static List params() { + return Arrays.asList( + Arguments.of( "debug", null ), + Arguments.of( null, null ), + Arguments.of( null, 0 ), + Arguments.of( null, NON_ZERO_DELAY ), + Arguments.of( "near-real-time", null ), + Arguments.of( "near-real-time", 0 ), + Arguments.of( "near-real-time", NON_ZERO_DELAY ) + ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); - - private final String ioStrategyName; - private final Integer commitInterval; + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - public LuceneIndexWriterCommitIT(String ioStrategyName, Integer commitInterval) { - this.ioStrategyName = ioStrategyName; - this.commitInterval = commitInterval; - } - - @Test - public void commitStrategyNone() throws IOException { - setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_AND_DROP ); + @ParameterizedTest(name = "I/O strategy {0}, commit_interval {1}") + @MethodSource("params") + void commitStrategyNone(String ioStrategyName, Integer commitInterval) throws IOException { + setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_AND_DROP, ioStrategyName, commitInterval ); // Initially our document is not in the index assertThat( countDocsOnDisk() ).isEqualTo( 0 ); @@ -95,9 +88,10 @@ public void commitStrategyNone() throws IOException { } ); } - @Test - public void commitStrategyForce() throws IOException { - setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_AND_DROP ); + @ParameterizedTest(name = "I/O strategy {0}, commit_interval {1}") + @MethodSource("params") + void commitStrategyForce(String ioStrategyName, Integer commitInterval) throws IOException { + setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_AND_DROP, ioStrategyName, commitInterval ); // Initially our document is not in the index assertThat( countDocsOnDisk() ).isEqualTo( 0 ); @@ -117,9 +111,13 @@ public void commitStrategyForce() throws IOException { /** * Test that changes are actually committed when closing the integration. */ - @Test - public void integrationClose() throws IOException { - StubMapping mapping = setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY ); + @ParameterizedTest(name = "I/O strategy {0}, commit_interval {1}") + @MethodSource("params") + void integrationClose(String ioStrategyName, Integer commitInterval) throws IOException { + StubMapping mapping = setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY, + ioStrategyName, + commitInterval + ); // Initially our document is not in the index assertThat( countDocsOnDisk() ).isEqualTo( 0 ); @@ -152,7 +150,8 @@ private int countDocsOnDisk() throws IOException { ); } - private StubMapping setup(StubMappingSchemaManagementStrategy schemaManagementStrategy) { + private StubMapping setup(StubMappingSchemaManagementStrategy schemaManagementStrategy, String ioStrategyName, + Integer commitInterval) { return setupHelper.start() .withSchemaManagement( schemaManagementStrategy ) .withIndex( index ) diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterSettingsIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterSettingsIT.java index f087e94e70d..d70b48d9dd9 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterSettingsIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterSettingsIT.java @@ -22,13 +22,13 @@ import org.hibernate.search.backend.lucene.lowlevel.writer.impl.LoggerInfoStream; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; @@ -36,16 +36,16 @@ import org.apache.lucene.index.MergePolicy; import org.apache.lucene.util.InfoStream; -public class LuceneIndexWriterSettingsIT { +class LuceneIndexWriterSettingsIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); @Test @TestForIssue(jiraKey = "HSEARCH-3776") - public void defaults() { + void defaults() { setup( properties -> {} ); LuceneIndexManagerImpl luceneIndexManager = index.unwrapForTests( LuceneIndexManagerImpl.class ); @@ -100,7 +100,7 @@ public void defaults() { @TestForIssue(jiraKey = "HSEARCH-3776") @PortedFromSearch5( original = "org.hibernate.search.test.configuration.LuceneIndexingParametersTest.testSpecificTypeParametersOverride") - public void custom() { + void custom() { setup( properties -> { properties.accept( LuceneIndexSettings.IO_WRITER_MAX_BUFFERED_DOCS, "420" ); properties.accept( LuceneIndexSettings.IO_WRITER_RAM_BUFFER_SIZE, "420" ); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterSettingsPerShardIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterSettingsPerShardIT.java index 8f32dd1d01a..d3e5b5f5169 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterSettingsPerShardIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/lowlevel/writer/LuceneIndexWriterSettingsPerShardIT.java @@ -11,29 +11,31 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.util.List; +import java.util.function.Function; import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.backend.lucene.index.impl.LuceneIndexManagerImpl; import org.hibernate.search.backend.lucene.index.impl.Shard; import org.hibernate.search.backend.lucene.lowlevel.index.impl.IndexAccessorImpl; import org.hibernate.search.integrationtest.backend.lucene.sharding.AbstractSettingsPerShardIT; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.LiveIndexWriterConfig; @TestForIssue(jiraKey = "HSEARCH-3636") -public class LuceneIndexWriterSettingsPerShardIT extends AbstractSettingsPerShardIT { +class LuceneIndexWriterSettingsPerShardIT extends AbstractSettingsPerShardIT { - public LuceneIndexWriterSettingsPerShardIT(String ignoredLabel, SearchSetupHelper setupHelper, List shardIds) { - super( ignoredLabel, setupHelper, shardIds ); - } - - @Test - public void test() { + @ParameterizedTest(name = "{0} - {2}") + @MethodSource("params") + void test(String ignoredLabel, Function> setupStrategyFunction, + List shardIds) { + init( ignoredLabel, setupStrategyFunction, shardIds ); setupHelper.start().withIndex( index ) .withIndexProperty( index.name(), LuceneIndexSettings.IO_WRITER_MAX_BUFFERED_DOCS, "420" ) .withIndexProperty( index.name(), diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/mapping/LuceneFieldAttributesIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/mapping/LuceneFieldAttributesIT.java index 65658ef5c9f..82526f99412 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/mapping/LuceneFieldAttributesIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/mapping/LuceneFieldAttributesIT.java @@ -20,31 +20,31 @@ import org.hibernate.search.engine.backend.types.TermVector; import org.hibernate.search.engine.backend.types.dsl.StringIndexFieldTypeOptionsStep; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.analysis.ngram.NGramTokenizerFactory; import org.apache.lucene.analysis.payloads.TokenOffsetPayloadTokenFilterFactory; import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexableField; -public class LuceneFieldAttributesIT { +class LuceneFieldAttributesIT { private static final String ANALYZER_NAME = "my-analyzer"; private static final String TEXT = "This is a text containing things. Red house with a blue carpet on the road..."; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start() .withBackendProperty( LuceneBackendSettings.ANALYSIS_CONFIGURER, (LuceneAnalysisConfigurer) ctx -> ctx @@ -61,7 +61,7 @@ public void setup() { } @Test - public void verifyNorms() { + void verifyNorms() { Document document = loadDocument(); // norms false => omit-norms true @@ -74,7 +74,7 @@ public void verifyNorms() { } @Test - public void verifyTermVector() { + void verifyTermVector() { Document document = loadDocument(); IndexableField field = document.getField( "text" ); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/mapping/LuceneFieldTypesIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/mapping/LuceneFieldTypesIT.java index 0b54dd1c554..bd992727bec 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/mapping/LuceneFieldTypesIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/mapping/LuceneFieldTypesIT.java @@ -17,28 +17,28 @@ import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.document.Document; -public class LuceneFieldTypesIT { +class LuceneFieldTypesIT { private static final String TEXT_1 = "This is a text containing things. Red house with a blue carpet on the road..."; private static final String TEXT_2 = "This is a text containing other things. Such as move the line on the right margin..."; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start() .withIndex( index ) .setup(); @@ -48,7 +48,7 @@ public void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-1640") - public void verifyProjectionsOnDifferentTypes() { + void verifyProjectionsOnDifferentTypes() { SearchQuery query = index.createScope().query() .select( f -> f.extension( LuceneExtension.get() ).document() diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerCreationIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerCreationIT.java index bf94d872413..717c7d50d73 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerCreationIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerCreationIT.java @@ -9,49 +9,45 @@ import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.integrationtest.backend.lucene.testsupport.util.LuceneIndexContentUtils; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.Futures; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class LuceneIndexSchemaManagerCreationIT { +class LuceneIndexSchemaManagerCreationIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return LuceneIndexSchemaManagerOperation.creating(); + public static List params() { + return LuceneIndexSchemaManagerOperation.creating().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "field", f -> f.asString() ) .toReference() ); - private final LuceneIndexSchemaManagerOperation operation; - - public LuceneIndexSchemaManagerCreationIT(LuceneIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3759") - public void simple() throws IOException { + void simple(LuceneIndexSchemaManagerOperation operation) throws IOException { assertThat( indexExists() ).isFalse(); setup(); - create(); + create( operation ); assertThat( indexExists() ).isTrue(); } @@ -60,7 +56,7 @@ private boolean indexExists() throws IOException { return LuceneIndexContentUtils.indexExists( setupHelper, index.name() ); } - private void create() { + private void create(LuceneIndexSchemaManagerOperation operation) { Futures.unwrappedExceptionJoin( operation.apply( index.schemaManager(), OperationSubmitter.blocking() ) ); } diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerCreationOrPreservationIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerCreationOrPreservationIT.java index 74848e2746c..a9a3e4fdad2 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerCreationOrPreservationIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerCreationOrPreservationIT.java @@ -10,59 +10,56 @@ import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.referenceProvider; import java.io.IOException; -import java.util.EnumSet; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.backend.lucene.lowlevel.common.impl.MetadataFields; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; import org.hibernate.search.integrationtest.backend.lucene.testsupport.util.LuceneIndexContentUtils; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.Futures; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class LuceneIndexSchemaManagerCreationOrPreservationIT { +class LuceneIndexSchemaManagerCreationOrPreservationIT { - @Parameterized.Parameters(name = "With operation {0}") - public static EnumSet operations() { - return LuceneIndexSchemaManagerOperation.creatingOrPreserving(); + public static List params() { + return LuceneIndexSchemaManagerOperation.creatingOrPreserving().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); - private final LuceneIndexSchemaManagerOperation operation; - - public LuceneIndexSchemaManagerCreationOrPreservationIT(LuceneIndexSchemaManagerOperation operation) { - this.operation = operation; - } - - @Test + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3759") - public void doesNotExist() throws IOException { + void doesNotExist(LuceneIndexSchemaManagerOperation operation) throws IOException { assertThat( indexExists() ).isFalse(); setup(); - createOrPreserve(); + createOrPreserve( operation ); assertThat( indexExists() ).isTrue(); } - @Test + @ParameterizedTest(name = "With operation {0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3759") - public void alreadyExists() throws IOException { + void alreadyExists(LuceneIndexSchemaManagerOperation operation) throws IOException { assertThat( indexExists() ).isFalse(); setup(); - createOrPreserve(); + createOrPreserve( operation ); assertThat( indexExists() ).isTrue(); @@ -72,7 +69,7 @@ public void alreadyExists() throws IOException { assertThat( countDocsOnDisk() ).isEqualTo( 1 ); - createOrPreserve(); + createOrPreserve( operation ); assertThat( indexExists() ).isTrue(); assertThat( countDocsOnDisk() ).isEqualTo( 1 ); @@ -89,7 +86,7 @@ private int countDocsOnDisk() throws IOException { ); } - private void createOrPreserve() { + private void createOrPreserve(LuceneIndexSchemaManagerOperation operation) { Futures.unwrappedExceptionJoin( operation.apply( index.schemaManager(), OperationSubmitter.blocking() ) ); } diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerDropAndCreateIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerDropAndCreateIT.java index 3852ccf7551..382d4ef7829 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerDropAndCreateIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerDropAndCreateIT.java @@ -15,18 +15,18 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; import org.hibernate.search.integrationtest.backend.lucene.testsupport.util.LuceneIndexContentUtils; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.Futures; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class LuceneIndexSchemaManagerDropAndCreateIT { +class LuceneIndexSchemaManagerDropAndCreateIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "field", f -> f.asString() ) @@ -35,7 +35,7 @@ public class LuceneIndexSchemaManagerDropAndCreateIT { @Test @TestForIssue(jiraKey = "HSEARCH-3759") - public void test() throws IOException { + void test() throws IOException { assertThat( indexExists() ).isFalse(); setup(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerDropIfExistingIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerDropIfExistingIT.java index d92a62af04c..d3a249a8080 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerDropIfExistingIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerDropIfExistingIT.java @@ -15,18 +15,18 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; import org.hibernate.search.integrationtest.backend.lucene.testsupport.util.LuceneIndexContentUtils; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.Futures; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class LuceneIndexSchemaManagerDropIfExistingIT { +class LuceneIndexSchemaManagerDropIfExistingIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final StubMappedIndex index = StubMappedIndex.ofNonRetrievable( root -> root.field( "field", f -> f.asString() ) @@ -35,7 +35,7 @@ public class LuceneIndexSchemaManagerDropIfExistingIT { @Test @TestForIssue(jiraKey = "HSEARCH-3759") - public void doesNotExist() throws IOException { + void doesNotExist() throws IOException { assertThat( indexExists() ).isFalse(); setup(); @@ -61,7 +61,7 @@ public void doesNotExist() throws IOException { @Test @TestForIssue(jiraKey = "HSEARCH-3759") - public void alreadyExists() throws IOException { + void alreadyExists() throws IOException { assertThat( indexExists() ).isFalse(); setup(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerValidationIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerValidationIT.java index 6f845c51794..6af10d43fd1 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerValidationIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/schema/management/LuceneIndexSchemaManagerValidationIT.java @@ -13,25 +13,25 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.integrationtest.backend.lucene.testsupport.util.LuceneIndexContentUtils; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class LuceneIndexSchemaManagerValidationIT { +class LuceneIndexSchemaManagerValidationIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final StubMappedIndex index = StubMappedIndex.withoutFields(); @Test @TestForIssue(jiraKey = "HSEARCH-3759") - public void doesNotExist() throws IOException { + void doesNotExist() throws IOException { assertThat( indexExists() ).isFalse(); setup(); @@ -55,7 +55,7 @@ public void doesNotExist() throws IOException { @Test @TestForIssue(jiraKey = "HSEARCH-3759") - public void alreadyExists() throws IOException { + void alreadyExists() throws IOException { assertThat( indexExists() ).isFalse(); setup(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneBoolSearchPredicateIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneBoolSearchPredicateIT.java index 2b9f9dbd395..98b54125214 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneBoolSearchPredicateIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneBoolSearchPredicateIT.java @@ -14,31 +14,31 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class LuceneBoolSearchPredicateIT { +class LuceneBoolSearchPredicateIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); } @Test @TestForIssue(jiraKey = "HSEARCH-3535") - public void minimumShouldMatch_outOfBounds() { + void minimumShouldMatch_outOfBounds() { StubMappingScope scope = index.createScope(); assertThatThrownBy( @@ -56,7 +56,7 @@ public void minimumShouldMatch_outOfBounds() { } @Test - public void resultingQueryOptimization() { + void resultingQueryOptimization() { SearchPredicateFactory f = index.createScope().predicate(); assertThat( index.query() @@ -94,7 +94,7 @@ public void resultingQueryOptimization() { } @Test - public void resultingQueryOptimizationWithBoost() { + void resultingQueryOptimizationWithBoost() { SearchPredicateFactory f = index.createScope().predicate(); // by default Lucene bool query would have a filter on match all assertThat( @@ -116,7 +116,7 @@ public void resultingQueryOptimizationWithBoost() { } @Test - public void nested() { + void nested() { String expectedQueryString = "+(+fieldName:test +ToParentBlockJoinQuery (#__HSEARCH_type:child #__HSEARCH_nested_document_path:nested +(+nested.integer:[5 TO 10] +nested.text:value))) #__HSEARCH_type:main"; @@ -152,7 +152,7 @@ public void nested() { } @Test - public void onlyNested() { + void onlyNested() { //bool query remains as there are > 1 clause assertThat( index.query().where( f -> f.nested( "nested" ) diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneFloatingPointInfinitySearchIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneFloatingPointInfinitySearchIT.java index e15157155cc..7d250abf42a 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneFloatingPointInfinitySearchIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneFloatingPointInfinitySearchIT.java @@ -22,34 +22,34 @@ import org.hibernate.search.engine.search.aggregation.AggregationKey; import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.StandardFieldMapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.data.Range; import org.hibernate.search.util.common.data.RangeBoundInclusion; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class LuceneFloatingPointInfinitySearchIT { +class LuceneFloatingPointInfinitySearchIT { private static final String AGGREGATION_NAME = "aggregationName"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test @TestForIssue(jiraKey = "HSEARCH-3685") - public void float_infinityIncluded() { + void float_infinityIncluded() { String fieldPath = index.binding().floatFieldModel.relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -75,7 +75,7 @@ public void float_infinityIncluded() { @Test @TestForIssue(jiraKey = "HSEARCH-3685") - public void float_infinityExcluded() { + void float_infinityExcluded() { String fieldPath = index.binding().floatFieldModel.relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -109,7 +109,7 @@ public void float_infinityExcluded() { @Test @TestForIssue(jiraKey = "HSEARCH-3685") - public void double_infinityIncluded() { + void double_infinityIncluded() { String fieldPath = index.binding().doubleFieldModel.relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -135,7 +135,7 @@ public void double_infinityIncluded() { @Test @TestForIssue(jiraKey = "HSEARCH-3685") - public void double_infinityExcluded() { + void double_infinityExcluded() { String fieldPath = index.binding().doubleFieldModel.relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneMatchSearchPredicateIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneMatchSearchPredicateIT.java index 8987cad65ed..dc932bd72e4 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneMatchSearchPredicateIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneMatchSearchPredicateIT.java @@ -13,30 +13,30 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class LuceneMatchSearchPredicateIT { +class LuceneMatchSearchPredicateIT { private static final String TEST_TERM = "ThisWillBeLowercasedByTheNormalizer"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void match_skipAnalysis_normalizedStringField() { + void match_skipAnalysis_normalizedStringField() { SearchQuery query = index.createScope().query() .where( f -> f.match().field( "normalizedStringField" ).matching( TEST_TERM ) ) .toQuery(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneNoLimitSearchIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneNoLimitSearchIT.java index e63433bd2d0..6b19a087cf2 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneNoLimitSearchIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneNoLimitSearchIT.java @@ -17,32 +17,32 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.search.query.SearchResult; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-3947") -public class LuceneNoLimitSearchIT { +class LuceneNoLimitSearchIT { public static final int INDEX_SIZE = 100_000; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void fetchAll() { + void fetchAll() { SearchQuery query = index.createScope().query() .where( f -> f.match().field( "field" ).matching( "739" ) ) .toQuery(); @@ -55,7 +55,7 @@ public void fetchAll() { } @Test - public void fetchAll_lessThan100Matches() { + void fetchAll_lessThan100Matches() { SearchQuery query = index.createScope().query() .where( f -> f.range().field( "field" ).between( "73979", "73997" ) ) .toQuery(); @@ -66,7 +66,7 @@ public void fetchAll_lessThan100Matches() { } @Test - public void fetchAll_between100And10000Matches() { + void fetchAll_between100And10000Matches() { SearchQuery query = index.createScope().query() .where( f -> f.range().field( "field" ).between( "73937", "79397" ) ) .toQuery(); @@ -77,7 +77,7 @@ public void fetchAll_between100And10000Matches() { } @Test - public void fetchAll_moreThan10000Matches() { + void fetchAll_moreThan10000Matches() { SearchQuery query = index.createScope().query() .where( f -> f.range().field( "field" ).between( "37973", "73937" ) ) .toQuery(); @@ -88,7 +88,7 @@ public void fetchAll_moreThan10000Matches() { } @Test - public void fetchAll_totalHitCountThreshold() { + void fetchAll_totalHitCountThreshold() { SearchQuery query = index.createScope().query() .where( f -> f.match().field( "field" ).matching( "739" ) ) .totalHitCountThreshold( 5 ) @@ -102,7 +102,7 @@ public void fetchAll_totalHitCountThreshold() { } @Test - public void fetchAllHits() { + void fetchAllHits() { SearchQuery query = index.createScope().query() .where( f -> f.match().field( "field" ).matching( "739" ) ) .toQuery(); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneNormalizeWildcardExpressionsIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneNormalizeWildcardExpressionsIT.java index 5dad03fc9e2..b5f871efa7b 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneNormalizeWildcardExpressionsIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneNormalizeWildcardExpressionsIT.java @@ -14,26 +14,25 @@ import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.search.predicate.WildcardPredicateSpecificsIT; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** - * Extends {@link WildcardPredicateSpecificsIT}, + * Extends {@code org.hibernate.search.integrationtest.backend.tck.search.predicate.WildcardPredicateSpecificsIT}, * verifying the normalization of the terms to match in wildcard/prefix predicates, * when an analyzer (not just a normalizer) has been defined on the target field. *

* This case seems to be not already supported for the current version of Elasticsearch server. */ @TestForIssue(jiraKey = "HSEARCH-3612") -public class LuceneNormalizeWildcardExpressionsIT { +class LuceneNormalizeWildcardExpressionsIT { private static final String DOCUMENT_1 = "document1"; private static final String DOCUMENT_2 = "document2"; @@ -52,19 +51,19 @@ public class LuceneNormalizeWildcardExpressionsIT { private static final String TEXT_MATCHING_PATTERN_3 = "A had to call the landlord."; private static final String TEXT_MATCHING_PATTERN_2_AND_3 = "I had some interaction with that lad."; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void wildcard_normalizeMatchingExpression() { + void wildcard_normalizeMatchingExpression() { StubMappingScope scope = index.createScope(); Function> createQuery = queryString -> scope.query() .where( f -> f.wildcard().field( "analyzed" ).matching( queryString ) ) @@ -81,7 +80,7 @@ public void wildcard_normalizeMatchingExpression() { } @Test - public void wildcard_tokenizeMatchingExpression() { + void wildcard_tokenizeMatchingExpression() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() .where( f -> f.wildcard().field( "analyzed" ).matching( PATTERN_1_AND_2 ) ) diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchMultiIndexIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchMultiIndexIT.java index d594d6a0bd3..eba0085426c 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchMultiIndexIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchMultiIndexIT.java @@ -8,30 +8,29 @@ import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.search.SearchMultiIndexIT; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** - * This is an extension of the backend TCK test {@link SearchMultiIndexIT}. + * This is an extension of the backend TCK test {@code org.hibernate.search.integrationtest.backend.tck.search.SearchMultiIndexIT}. */ -@RunWith(Parameterized.class) -public class LuceneSearchMultiIndexIT { +class LuceneSearchMultiIndexIT { private static final String STRING_1 = "string_1"; private static final String STRING_2 = "string_2"; @@ -48,27 +47,19 @@ public class LuceneSearchMultiIndexIT { private static final String DOCUMENT_2_1 = "2_1"; - private final String directoryType; - - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index1 = SimpleMappedIndex.of( IndexBinding1::new ).name( "index1" ); private final SimpleMappedIndex index2 = SimpleMappedIndex.of( IndexBinding2::new ).name( "index2" );; - @Parameters(name = "Lucene directory type {0}") - public static Object[] data() { - return new Object[] { "local-heap", "local-filesystem" }; - } - - public LuceneSearchMultiIndexIT(String directoryType) { - this.directoryType = directoryType; + public static List params() { + return Arrays.asList( Arguments.of( "local-heap" ), Arguments.of( "local-filesystem" ) ); } - @Before - public void setup() { + public void init(String directoryType) { setupHelper.start() .withBackendProperty( "directory.type", directoryType ) .withIndexes( index1, index2 ) @@ -77,8 +68,10 @@ public void setup() { initData(); } - @Test - public void field_in_one_index_only_is_supported_for_sorting() { + @ParameterizedTest(name = "Lucene directory type {0}") + @MethodSource("params") + void field_in_one_index_only_is_supported_for_sorting(String directoryType) { + init( directoryType ); StubMappingScope scope = index1.createScope( index2 ); SearchQuery query = scope.query() diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsMergeFieldSortIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsMergeFieldSortIT.java index f58bdfee943..240b9c52863 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsMergeFieldSortIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsMergeFieldSortIT.java @@ -9,7 +9,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatResult; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider; -import static org.junit.Assume.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import java.time.MonthDay; import java.time.temporal.Temporal; @@ -33,16 +33,16 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.SingleFieldIndexBinding; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.apache.lucene.search.Sort; import org.apache.lucene.search.TopDocs; @@ -56,17 +56,14 @@ *

* This is a use case in Infinispan, in particular. */ -@RunWith(Parameterized.class) -public class LuceneSearchTopDocsMergeFieldSortIT { +class LuceneSearchTopDocsMergeFieldSortIT { - private static Set> supportedFieldTypes; - private static List> dataSets; + private static final Set> supportedFieldTypes = new LinkedHashSet<>(); + private static final List> dataSets = new ArrayList<>(); - @Parameterized.Parameters(name = "{0} - {2} - {1}") - public static Object[][] parameters() { - supportedFieldTypes = new LinkedHashSet<>(); - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + + static { for ( FieldTypeDescriptor fieldType : FieldTypeDescriptor.getAll() ) { if ( fieldType.isFieldSortSupported() ) { supportedFieldTypes.add( fieldType ); @@ -78,18 +75,21 @@ public static Object[][] parameters() { dataSets.add( dataSetForAsc ); DataSet dataSetForDesc = new DataSet<>( fieldStructure, fieldType, null, SortMode.MAX ); dataSets.add( dataSetForDesc ); - parameters.add( new Object[] { fieldStructure, fieldType, null, dataSetForAsc, dataSetForDesc } ); + parameters.add( Arguments.of( fieldStructure, fieldType, null, dataSetForAsc, dataSetForDesc ) ); for ( SortMode sortMode : SortMode.values() ) { // When the sort mode is defined, we only need one dataset. dataSetForAsc = new DataSet<>( fieldStructure, fieldType, sortMode, sortMode ); dataSets.add( dataSetForAsc ); dataSetForDesc = dataSetForAsc; - parameters.add( new Object[] { fieldStructure, fieldType, sortMode, dataSetForAsc, dataSetForDesc } ); + parameters.add( Arguments.of( fieldStructure, fieldType, sortMode, dataSetForAsc, dataSetForDesc ) ); } } } } - return parameters.toArray( new Object[0][] ); + } + + public static List params() { + return parameters; } private static final int SEGMENT_0 = 0; @@ -99,16 +99,16 @@ public static Object[][] parameters() { private static final int DOCUMENT_2_ORDINAL = 3; private static final int DOCUMENT_3_ORDINAL = 5; - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final Function bindingFactory = root -> SingleFieldIndexBinding.create( root, supportedFieldTypes, c -> c.sortable( Sortable.YES ) ); private static final SimpleMappedIndex index = SimpleMappedIndex.of( bindingFactory ); - @BeforeClass - public static void setup() { + @BeforeAll + static void init() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -118,31 +118,24 @@ public static void setup() { indexer.join(); } - private final TestedFieldStructure fieldStructure; - private final FieldTypeDescriptor fieldType; - private final SortMode sortMode; - private final DataSet dataSetForAsc; - private final DataSet dataSetForDesc; - - public LuceneSearchTopDocsMergeFieldSortIT(TestedFieldStructure fieldStructure, + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") + void asc(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType, SortMode sortMode, DataSet dataSetForAsc, DataSet dataSetForDesc) { - this.fieldStructure = fieldStructure; - this.fieldType = fieldType; - this.sortMode = sortMode; - this.dataSetForAsc = dataSetForAsc; - this.dataSetForDesc = dataSetForDesc; - } - - @Test - public void asc() { - assumeTestParametersWork(); + assumeTestParametersWork( sortMode, fieldStructure, fieldType ); DataSet dataSet = dataSetForAsc; - LuceneSearchQuery segment0Query = - matchNonEmptySortedByFieldQuery( dataSet, SEGMENT_0, SortOrder.ASC ); - LuceneSearchQuery segment1Query = - matchNonEmptySortedByFieldQuery( dataSet, SEGMENT_1, SortOrder.ASC ); + LuceneSearchQuery segment0Query = matchNonEmptySortedByFieldQuery( dataSet, SEGMENT_0, SortOrder.ASC, + fieldStructure, + fieldType, + sortMode + ); + LuceneSearchQuery segment1Query = matchNonEmptySortedByFieldQuery( dataSet, SEGMENT_1, SortOrder.ASC, + fieldStructure, + fieldType, + sortMode + ); LuceneSearchResult segment0Result = segment0Query.fetch( 10 ); LuceneSearchResult segment1Result = segment1Query.fetch( 10 ); assertThatResult( segment0Result ).fromQuery( segment0Query ) @@ -160,15 +153,26 @@ public void asc() { } // Also check descending order, to be sure the above didn't just pass by chance - @Test - public void desc() { - assumeTestParametersWork(); + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") + void desc(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( sortMode, fieldStructure, fieldType ); DataSet dataSet = dataSetForDesc; LuceneSearchQuery segment0Query = - matchNonEmptySortedByFieldQuery( dataSet, SEGMENT_0, SortOrder.DESC ); + matchNonEmptySortedByFieldQuery( dataSet, SEGMENT_0, SortOrder.DESC, + fieldStructure, + fieldType, + sortMode + ); LuceneSearchQuery segment1Query = - matchNonEmptySortedByFieldQuery( dataSet, SEGMENT_1, SortOrder.DESC ); + matchNonEmptySortedByFieldQuery( dataSet, SEGMENT_1, SortOrder.DESC, + fieldStructure, + fieldType, + sortMode + ); LuceneSearchResult segment0Result = segment0Query.fetch( 10 ); LuceneSearchResult segment1Result = segment1Query.fetch( 10 ); assertThatResult( segment0Result ).fromQuery( segment0Query ) @@ -186,19 +190,21 @@ public void desc() { } private LuceneSearchQuery matchNonEmptySortedByFieldQuery(DataSet dataSet, int segment, - SortOrder sortOrder) { + SortOrder sortOrder, TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType, + SortMode sortMode) { StubMappingScope scope = index.createScope(); return scope.query().extension( LuceneExtension.get() ) .where( f -> f.matchAll() .except( f.id().matchingAny( Arrays.asList( dataSet.seg0EmptyDocId, dataSet.seg1EmptyDocId ) ) ) ) .sort( f -> applyFilter( applySortMode( - scope.sort().field( getFieldPath() ).order( sortOrder ) - ) ) ) + scope.sort().field( getFieldPath( fieldStructure, fieldType ) ).order( sortOrder ), + sortMode + ), fieldStructure ) ) .routing( dataSet.routingKey( segment ) ) .toQuery(); } - private FieldSortOptionsStep applySortMode(FieldSortOptionsStep optionsStep) { + private FieldSortOptionsStep applySortMode(FieldSortOptionsStep optionsStep, SortMode sortMode) { if ( sortMode != null ) { return optionsStep.mode( sortMode ); } @@ -207,7 +213,8 @@ private LuceneSearchQuery matchNonEmptySortedByFieldQuery(Dat } } - private FieldSortOptionsStep applyFilter(FieldSortOptionsStep optionsStep) { + private FieldSortOptionsStep applyFilter(FieldSortOptionsStep optionsStep, + TestedFieldStructure fieldStructure) { if ( fieldStructure.isInNested() ) { return optionsStep.filter( f -> f.match() .field( index.binding().getDiscriminatorFieldPath( fieldStructure ) ) @@ -228,30 +235,34 @@ private TopFieldDocs[] retrieveTopDocs(LuceneSearchQuery query, LuceneSearchR return allTopDocs; } - private void assumeTestParametersWork() { + private void assumeTestParametersWork(SortMode sortMode, TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType) { assumeFalse( - "This combination is not expected to work", - isMedianWithNestedField() || isSumOrAvgOrMedianWithStringField() || isSumWithTemporalField() + isMedianWithNestedField( sortMode, fieldStructure ) + || + isSumOrAvgOrMedianWithStringField( fieldType, sortMode ) || + isSumWithTemporalField( sortMode, fieldType ), + "This combination is not expected to work" ); } - private boolean isSumOrAvgOrMedianWithStringField() { + private boolean isSumOrAvgOrMedianWithStringField(FieldTypeDescriptor fieldType, SortMode sortMode) { return EnumSet.of( SortMode.SUM, SortMode.AVG, SortMode.MEDIAN ).contains( sortMode ) && String.class.equals( fieldType.getJavaType() ); } - private boolean isSumWithTemporalField() { + private boolean isSumWithTemporalField(SortMode sortMode, FieldTypeDescriptor fieldType) { return SortMode.SUM.equals( sortMode ) && ( Temporal.class.isAssignableFrom( fieldType.getJavaType() ) || MonthDay.class.equals( fieldType.getJavaType() ) ); } - private boolean isMedianWithNestedField() { + private boolean isMedianWithNestedField(SortMode sortMode, TestedFieldStructure fieldStructure) { return SortMode.MEDIAN.equals( sortMode ) && fieldStructure.isInNested(); } - private String getFieldPath() { + private String getFieldPath(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType) { return index.binding().getFieldPath( fieldStructure, fieldType ); } diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsMergeScoreSortIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsMergeScoreSortIT.java index 144f64c0649..97a9f17bdfd 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsMergeScoreSortIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsMergeScoreSortIT.java @@ -17,13 +17,13 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.search.sort.dsl.SortOrder; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.search.Sort; import org.apache.lucene.search.TopDocs; @@ -37,7 +37,7 @@ *

* This is a use case in Infinispan, in particular. */ -public class LuceneSearchTopDocsMergeScoreSortIT { +class LuceneSearchTopDocsMergeScoreSortIT { private static final String SEGMENT_0 = "seg0"; private static final String SEGMENT_1 = "seg1"; @@ -49,20 +49,20 @@ public class LuceneSearchTopDocsMergeScoreSortIT { private static final String SEGMENT_1_DOC_1 = "1_1"; private static final String SEGMENT_1_DOC_NON_MATCHING = "1_nonMatching"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void desc() { + void desc() { LuceneSearchQuery segment0Query = matchTextSortedByScoreQuery( SortOrder.DESC, SEGMENT_0 ); LuceneSearchQuery segment1Query = matchTextSortedByScoreQuery( SortOrder.DESC, SEGMENT_1 ); LuceneSearchResult segment0Result = segment0Query.fetch( 10 ); @@ -86,7 +86,7 @@ public void desc() { // 1. to be sure the above didn't just pass by chance; // 2. because the TopDocs merging method is not the same in that case. @Test - public void asc() { + void asc() { LuceneSearchQuery segment0Query = matchTextSortedByScoreQuery( SortOrder.ASC, SEGMENT_0 ); LuceneSearchQuery segment1Query = matchTextSortedByScoreQuery( SortOrder.ASC, SEGMENT_1 ); LuceneSearchResult segment0Result = segment0Query.fetch( 10 ); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsTotalHitCountOnMatchAllDocsIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsTotalHitCountOnMatchAllDocsIT.java index 81ff6b13134..5e531e03d86 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsTotalHitCountOnMatchAllDocsIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/search/LuceneSearchTopDocsTotalHitCountOnMatchAllDocsIT.java @@ -15,14 +15,14 @@ import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.TotalHits; @@ -35,17 +35,17 @@ *

* This is a use case in Infinispan, in particular. */ -public class LuceneSearchTopDocsTotalHitCountOnMatchAllDocsIT { +class LuceneSearchTopDocsTotalHitCountOnMatchAllDocsIT { private static final int DOCUMENT_COUNT = 2000; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); index.bulkIndexer() @@ -59,7 +59,7 @@ public static void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-4068") // The regression was spotted early, while introducing it in HSEARCH-4068 - public void matchAllDocs_sortByScoreDesc() { + void matchAllDocs_sortByScoreDesc() { LuceneSearchResult result = index.query().extension( LuceneExtension.get() ) .where( f -> f.matchAll() ) .fetch( 10 ); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/sharding/AbstractSettingsPerShardIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/sharding/AbstractSettingsPerShardIT.java index 8bbbcc90bd6..f8cdada9fb2 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/sharding/AbstractSettingsPerShardIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/sharding/AbstractSettingsPerShardIT.java @@ -7,62 +7,62 @@ package org.hibernate.search.integrationtest.backend.lucene.sharding; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; +import java.util.function.Function; import org.hibernate.search.engine.mapper.mapping.building.spi.IndexedEntityBindingContext; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.CollectionHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Rule; -import org.junit.rules.RuleChain; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; /** * A basic test for explicit sharding with explicit routing keys. */ -@RunWith(Parameterized.class) public abstract class AbstractSettingsPerShardIT { - @Parameterized.Parameters(name = "{0} - {2}") - public static Object[][] params() { + public static List params() { Set hashShardIds = CollectionHelper.asImmutableSet( "0", "1", "2", "3" ); Set explicitShardIds = CollectionHelper.asImmutableSet( "first", "second", "other", "yetanother" ); - return new Object[][] { - { - "hash", - new SearchSetupHelper( helper -> helper.createHashBasedShardingBackendSetupStrategy( 4 ) ), - new ArrayList<>( hashShardIds ) }, - { + return Arrays.asList( + Arguments.of( "hash", + (Function>) ( helper -> helper.createHashBasedShardingBackendSetupStrategy( 4 ) ), + new ArrayList<>( hashShardIds ) + ), + Arguments.of( "explicit", - new SearchSetupHelper( - ignored -> ShardingExplicitIT.explicitShardingBackendSetupStrategy( explicitShardIds ) ), - new ArrayList<>( explicitShardIds ) } - }; + (Function>) ( ignored -> ShardingExplicitIT.explicitShardingBackendSetupStrategy( + explicitShardIds ) ), + new ArrayList<>( explicitShardIds ) + ) + ); } protected final SimpleMappedIndex index = SimpleMappedIndex.ofAdvanced( IndexBinding::new ); - public final String strategy; + public String strategy; - public final SearchSetupHelper setupHelper; + @RegisterExtension + public SearchSetupHelper setupHelper = SearchSetupHelper.create(); - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); + public List shardIds; - @Rule - public final RuleChain rules; - - public final List shardIds; - - protected AbstractSettingsPerShardIT(String strategy, SearchSetupHelper setupHelper, List shardIds) { + protected void init(String strategy, Function> setupStrategyFunction, + List shardIds) { this.strategy = strategy; - this.setupHelper = setupHelper; + this.setupHelper.with( setupStrategyFunction ); this.shardIds = shardIds; - this.rules = RuleChain.outerRule( temporaryFolder ).around( setupHelper ); } protected final String routingKey(int i) { diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/sharding/ShardingExplicitIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/sharding/ShardingExplicitIT.java index 9db0d0a1d90..4f990a5aa6d 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/sharding/ShardingExplicitIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/sharding/ShardingExplicitIT.java @@ -19,7 +19,7 @@ import org.hibernate.search.util.common.impl.CollectionHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.IndexSearcher; @@ -29,7 +29,7 @@ /** * A basic test for explicit sharding with explicit routing keys. */ -public class ShardingExplicitIT extends AbstractShardingRoutingKeyIT { +class ShardingExplicitIT extends AbstractShardingRoutingKeyIT { protected static TckBackendSetupStrategy explicitShardingBackendSetupStrategy(Set shardIds) { return new LuceneTckBackendSetupStrategy() @@ -49,7 +49,7 @@ public ShardingExplicitIT() { } @Test - public void indexReaderAccessor() throws Exception { + void indexReaderAccessor() throws Exception { StubMappingScope scope = index.createScope(); try ( IndexReader indexReader = scope.extension( LuceneExtension.get() ).openIndexReader() ) { diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneIndexContentUtils.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneIndexContentUtils.java index 03aa80eb0b3..ebeda9da864 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneIndexContentUtils.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneIndexContentUtils.java @@ -8,7 +8,7 @@ import java.io.IOException; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.store.Directory; diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckBackendAccessor.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckBackendAccessor.java index 56f9cf12776..0a4db8cacb9 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckBackendAccessor.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckBackendAccessor.java @@ -20,8 +20,6 @@ import org.hibernate.search.util.common.impl.Throwables; import org.hibernate.search.util.impl.integrationtest.backend.lucene.LuceneTestIndexesPathConfiguration; -import org.junit.AssumptionViolatedException; - import org.jboss.logging.Logger; import org.apache.lucene.store.Directory; @@ -82,7 +80,7 @@ public void ensureFlushMergeRefreshOperationsFail(String indexName) { * The refresh in the Lucene backend actually doesn't touch the index at all, * so we don't have any way to trigger failures. */ - throw new AssumptionViolatedException( "Cannot simulate flush/merge/refresh failures for the Lucene backend" ); + throw new org.opentest4j.TestAbortedException( "Cannot simulate flush/merge/refresh failures for the Lucene backend" ); } public Directory openDirectory(String indexName) throws IOException { diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckTestRunner.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckTestRunner.java index 354765ba43f..da4935f7bb7 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckTestRunner.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/testsupport/util/LuceneTckTestRunner.java @@ -6,20 +6,24 @@ */ package org.hibernate.search.integrationtest.backend.lucene.testsupport.util; -import org.junit.extensions.cpsuite.ClasspathSuite; -import org.junit.runner.RunWith; +import org.junit.platform.suite.api.IncludeClassNamePatterns; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; +import org.junit.platform.suite.api.SuiteDisplayName; /** * Helper for running specific TCK tests against the Lucene backend from the IDE. * - *

Adapt the classpath filter as needed to run a single test or an entire test package. + *

Adapt the classpath filter as needed to run a single test or an entire test package. * * @author Gunnar Morling */ -@RunWith(ClasspathSuite.class) -@ClasspathSuite.ClassnameFilters({ - "!.*\\$.*", // Exclude nested tests, typically used with NestedRunner - ".*\\.tck\\..*" -}) +@Suite +@SuiteDisplayName("Lucene TCK tests Runner") +// Defines a "root" package, subpackages are included. Use Include/Exclude ClassNamePatterns annotations to limit the executed tests: +@SelectPackages("org.hibernate.search.integrationtest.backend.tck") +// Default class pattern does not include IT tests, hence we want to customize it a bit: +@IncludeClassNamePatterns({ ".*Test", ".*IT" }) public class LuceneTckTestRunner { + } diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/work/LuceneBackendWorkExecutorProviderIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/work/LuceneBackendWorkExecutorProviderIT.java index 0c2026ab13d..9db86af7821 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/work/LuceneBackendWorkExecutorProviderIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/work/LuceneBackendWorkExecutorProviderIT.java @@ -17,32 +17,32 @@ import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.common.execution.spi.DelegatingSimpleScheduledExecutor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class LuceneBackendWorkExecutorProviderIT { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class LuceneBackendWorkExecutorProviderIT { @Mock private LuceneWorkExecutorProvider backendWorkExecutorProvider; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); @Test - public void test() { + void test() { when( backendWorkExecutorProvider.writeExecutor( any() ) ).thenReturn( new DelegatingSimpleScheduledExecutor( new ScheduledThreadPoolExecutor( 1 ), true ) ); diff --git a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/work/LuceneIndexingNestedIT.java b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/work/LuceneIndexingNestedIT.java index 8735c59aff5..830a9472826 100644 --- a/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/work/LuceneIndexingNestedIT.java +++ b/integrationtest/backend/lucene/src/test/java/org/hibernate/search/integrationtest/backend/lucene/work/LuceneIndexingNestedIT.java @@ -24,38 +24,38 @@ import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; import org.hibernate.search.engine.backend.work.execution.spi.UnsupportedOperationBehavior; import org.hibernate.search.integrationtest.backend.lucene.testsupport.util.LuceneIndexContentUtils; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubSession; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test indexing, and more importantly updates and deletions, * when nested documents are involved. */ @TestForIssue(jiraKey = "HSEARCH-3834") -public class LuceneIndexingNestedIT { +class LuceneIndexingNestedIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private StubSession sessionContext; @Test - public void add() throws IOException { + void add() throws IOException { setup( MultiTenancyStrategyName.NONE ); assertThat( countWithField( "nestedObject.field1" ) ).isEqualTo( 1 ); } @Test - public void update_byTerm() throws IOException { + void update_byTerm() throws IOException { // No multitenancy, which means the backend will use indexWriter.updateDocuments(Term, Iterable) for updates setup( MultiTenancyStrategyName.NONE ); @@ -72,7 +72,7 @@ public void update_byTerm() throws IOException { } @Test - public void update_byQuery() throws IOException { + void update_byQuery() throws IOException { // Multitenancy enabled, which means the backend will use // indexWriter.deleteDocuments(Query) then indexWriter.addDocument for updates setup( MultiTenancyStrategyName.DISCRIMINATOR ); @@ -90,7 +90,7 @@ public void update_byQuery() throws IOException { } @Test - public void delete_byTerm() throws IOException { + void delete_byTerm() throws IOException { // No multitenancy, which means the backend will use indexWriter.deleteDocuments(Term) for deletion setup( MultiTenancyStrategyName.NONE ); @@ -103,7 +103,7 @@ public void delete_byTerm() throws IOException { } @Test - public void delete_byQuery() throws IOException { + void delete_byQuery() throws IOException { // Multitenancy enabled, which means the backend will use indexWriter.deleteDocuments(Query) for deletion setup( MultiTenancyStrategyName.DISCRIMINATOR ); @@ -116,7 +116,7 @@ public void delete_byQuery() throws IOException { } @Test - public void purge() throws IOException { + void purge() throws IOException { setup( MultiTenancyStrategyName.NONE ); index.createWorkspace( sessionContext ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/ObjectStructureIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/ObjectStructureIT.java index 32591dd918a..491c75d5519 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/ObjectStructureIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/ObjectStructureIT.java @@ -21,16 +21,16 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ObjectStructureIT { +class ObjectStructureIT { private static final String EXPECTED_NESTED_MATCH_ID = "nestedQueryShouldMatchId"; private static final String EXPECTED_NON_NESTED_MATCH_ID = "nonNestedQueryShouldMatchId"; @@ -45,20 +45,20 @@ public class ObjectStructureIT { private static final Integer NON_MATCHING_INTEGER = 442; private static final LocalDate NON_MATCHING_LOCAL_DATE = LocalDate.of( 2018, 2, 15 ); - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void index_error_invalidFieldForDocumentElement_root() { + void index_error_invalidFieldForDocumentElement_root() { assertThatThrownBy( () -> index.index( "willNotWork", document -> { DocumentElement flattenedObject = document.addObject( index.binding().flattenedObject.self ); flattenedObject.addValue( index.binding().string, "willNotWork" ); @@ -72,7 +72,7 @@ public void index_error_invalidFieldForDocumentElement_root() { } @Test - public void index_error_invalidFieldForDocumentElement_flattened() { + void index_error_invalidFieldForDocumentElement_flattened() { assertThatThrownBy( () -> index.index( "willNotWork", document -> document.addValue( index.binding().flattenedObject.string, "willNotWork" ) ) ) .isInstanceOf( SearchException.class ) @@ -83,7 +83,7 @@ public void index_error_invalidFieldForDocumentElement_flattened() { } @Test - public void index_error_invalidFieldForDocumentElement_nested() { + void index_error_invalidFieldForDocumentElement_nested() { assertThatThrownBy( () -> index.index( "willNotWork", document -> document.addValue( index.binding().nestedObject.string, "willNotWork" ) ) ) .isInstanceOf( SearchException.class ) @@ -94,7 +94,7 @@ public void index_error_invalidFieldForDocumentElement_nested() { } @Test - public void search_match() { + void search_match() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -123,7 +123,7 @@ public void search_match() { } @Test - public void search_range() { + void search_range() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -159,7 +159,7 @@ public void search_range() { } @Test - public void search_error_nonNestedField() { + void search_error_nonNestedField() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.predicate().nested( "flattenedObject" ) @@ -171,7 +171,7 @@ public void search_error_nonNestedField() { } @Test - public void search_error_nonObjectField() { + void search_error_nonObjectField() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.predicate().nested( "flattenedObject.string" ) @@ -182,7 +182,7 @@ public void search_error_nonObjectField() { } @Test - public void search_error_missingField() { + void search_error_missingField() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.predicate().nested( "doesNotExist" ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisBuiltinIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisBuiltinIT.java index 4093a6711d5..fd96ad9b4c4 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisBuiltinIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisBuiltinIT.java @@ -10,6 +10,7 @@ import java.util.Arrays; import java.util.List; +import java.util.function.Function; import org.hibernate.search.engine.backend.analysis.AnalyzerNames; import org.hibernate.search.engine.backend.common.DocumentReference; @@ -18,51 +19,48 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SingleFieldDocumentBuilder; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test indexing and searching with built-in analyzer definitions. * See {@link AnalyzerNames}. */ -@RunWith(Parameterized.class) -public class AnalysisBuiltinIT { +class AnalysisBuiltinIT { - @Parameterized.Parameters - public static List params() { + public static List params() { return Arrays.asList( // Test with no analysis configurer whatsoever - new SearchSetupHelper( TckBackendHelper::createAnalysisNotConfiguredBackendSetupStrategy ), + Arguments.of( (Function>) TckBackendHelper::createAnalysisNotConfiguredBackendSetupStrategy ), // Test with an analysis configurer that does not override the defaults but defines other analyzers - new SearchSetupHelper( TckBackendHelper::createAnalysisCustomBackendSetupStrategy ) + Arguments.of( (Function>) TckBackendHelper::createAnalysisCustomBackendSetupStrategy ) ); } - @Rule - public final SearchSetupHelper setupHelper; - + @RegisterExtension + public SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - public AnalysisBuiltinIT(SearchSetupHelper setupHelper) { - this.setupHelper = setupHelper; - } - - @Before - public void setup() { + public void init(Function> setupStrategyFunction) { + this.setupHelper.with( setupStrategyFunction ); setupHelper.start().withIndex( index ).setup(); } - @Test - public void analyzer_default() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void analyzer_default(Function> setupStrategyFunction) { + init( setupStrategyFunction ); SimpleFieldModel field = index.binding().defaultAnalyzer; initData( field ); @@ -83,8 +81,10 @@ public void analyzer_default() { .hasDocRefHitsAnyOrder( index.typeName(), "7" ); } - @Test - public void analyzer_standard() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void analyzer_standard(Function> setupStrategyFunction) { + init( setupStrategyFunction ); SimpleFieldModel field = index.binding().standardAnalyzer; initData( field ); @@ -105,8 +105,10 @@ public void analyzer_standard() { .hasDocRefHitsAnyOrder( index.typeName(), "7" ); } - @Test - public void analyzer_simple() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void analyzer_simple(Function> setupStrategyFunction) { + init( setupStrategyFunction ); SimpleFieldModel field = index.binding().simpleAnalyzer; initData( field ); @@ -127,8 +129,10 @@ public void analyzer_simple() { .hasDocRefHitsAnyOrder( index.typeName(), "7" ); } - @Test - public void analyzer_whitespace() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void analyzer_whitespace(Function> setupStrategyFunction) { + init( setupStrategyFunction ); SimpleFieldModel field = index.binding().whitespaceAnalyzer; initData( field ); @@ -149,8 +153,10 @@ public void analyzer_whitespace() { .hasDocRefHitsAnyOrder( index.typeName(), "7" ); } - @Test - public void analyzer_stop() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void analyzer_stop(Function> setupStrategyFunction) { + init( setupStrategyFunction ); SimpleFieldModel field = index.binding().stopAnalyzer; initData( field ); @@ -171,8 +177,10 @@ public void analyzer_stop() { .hasNoHits(); } - @Test - public void analyzer_keyword() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void analyzer_keyword(Function> setupStrategyFunction) { + init( setupStrategyFunction ); SimpleFieldModel field = index.binding().keywordAnalyzer; initData( field ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisBuiltinOverrideIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisBuiltinOverrideIT.java index a2648629725..da36f9d1151 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisBuiltinOverrideIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisBuiltinOverrideIT.java @@ -17,15 +17,15 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SingleFieldDocumentBuilder; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test indexing and searching with built-in analyzer definitions overridden by the user @@ -34,46 +34,46 @@ * Analyzers are expected to be overridden in such a way that they replace any text with their own name, * so that we can easily identify whether the override works or not. */ -public class AnalysisBuiltinOverrideIT { +class AnalysisBuiltinOverrideIT { - @Rule + @RegisterExtension public final SearchSetupHelper setupHelper = - new SearchSetupHelper( TckBackendHelper::createAnalysisBuiltinOverridesBackendSetupStrategy ); + SearchSetupHelper.create( TckBackendHelper::createAnalysisBuiltinOverridesBackendSetupStrategy ); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void analyzer_default() { + void analyzer_default() { verifyOverride( index.binding().defaultAnalyzer ); } @Test - public void analyzer_standard() { + void analyzer_standard() { verifyOverride( index.binding().standardAnalyzer ); } @Test - public void analyzer_simple() { + void analyzer_simple() { verifyOverride( index.binding().simpleAnalyzer ); } @Test - public void analyzer_whitespace() { + void analyzer_whitespace() { verifyOverride( index.binding().whitespaceAnalyzer ); } @Test - public void analyzer_stop() { + void analyzer_stop() { verifyOverride( index.binding().stopAnalyzer ); } @Test - public void analyzer_keyword() { + void analyzer_keyword() { verifyOverride( index.binding().keywordAnalyzer ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisCustomIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisCustomIT.java index 1032c218cd2..d402b3bf656 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisCustomIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/analysis/AnalysisCustomIT.java @@ -20,14 +20,14 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SingleFieldDocumentBuilder; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test indexing and searching with custom analyzer definitions. @@ -83,14 +83,14 @@ public enum AnalysisDefinitions { } } - @Rule + @RegisterExtension public final SearchSetupHelper setupHelper = - new SearchSetupHelper( TckBackendHelper::createAnalysisCustomBackendSetupStrategy ); + SearchSetupHelper.create( TckBackendHelper::createAnalysisCustomBackendSetupStrategy ); private SimpleMappedIndex index; @Test - public void normalizer_keyword() { + void normalizer_keyword() { setupWithNormalizer( AnalysisDefinitions.NORMALIZER_NOOP ); initData( b -> { b.emptyDocument( "empty" ); @@ -113,7 +113,7 @@ public void normalizer_keyword() { } @Test - public void normalizer_lowercase() { + void normalizer_lowercase() { setupWithNormalizer( AnalysisDefinitions.NORMALIZER_LOWERCASE ); initData( b -> { b.emptyDocument( "empty" ); @@ -138,7 +138,7 @@ public void normalizer_lowercase() { } @Test - public void normalizer_pattern_replacing() { + void normalizer_pattern_replacing() { setupWithNormalizer( AnalysisDefinitions.NORMALIZER_PATTERN_REPLACING ); initData( b -> { b.emptyDocument( "empty" ); @@ -161,7 +161,7 @@ public void normalizer_pattern_replacing() { } @Test - public void analyzer_keyword() { + void analyzer_keyword() { setupWithAnalyzer( AnalysisDefinitions.ANALYZER_NOOP ); initData( b -> { b.emptyDocument( "empty" ); @@ -184,7 +184,7 @@ public void analyzer_keyword() { } @Test - public void analyzer_whitespace_lowercase() { + void analyzer_whitespace_lowercase() { setupWithAnalyzer( AnalysisDefinitions.ANALYZER_WHITESPACE_LOWERCASE ); initData( b -> { b.emptyDocument( "empty" ); @@ -211,7 +211,7 @@ public void analyzer_whitespace_lowercase() { } @Test - public void analyzer_patterns_stopword() { + void analyzer_patterns_stopword() { setupWithAnalyzer( AnalysisDefinitions.ANALYZER_PATTERNS_STOPWORD ); initData( b -> { b.emptyDocument( "empty" ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/decimalscale/DecimalScaleIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/decimalscale/DecimalScaleIT.java index a47cbd4ebf8..1f696e0ed91 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/decimalscale/DecimalScaleIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/decimalscale/DecimalScaleIT.java @@ -19,15 +19,15 @@ import org.hibernate.search.engine.mapper.mapping.building.spi.IndexFieldTypeDefaultsProvider; import org.hibernate.search.engine.mapper.mapping.building.spi.IndexedEntityBindingContext; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DecimalScaleIT { +class DecimalScaleIT { /* * Longs only have 64 bits to represent the value, or approximately 18 decimal digits @@ -43,11 +43,11 @@ public class DecimalScaleIT { */ int INDEX_PRECISION = 16; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); @Test - public void noDecimalScale_bigDecimal() { + void noDecimalScale_bigDecimal() { assertThatThrownBy( () -> setupHelper.start() .withIndex( StubMappedIndex.ofNonRetrievable( root -> root.field( "noScaled", f -> f.asBigDecimal() ).toReference() @@ -60,7 +60,7 @@ public void noDecimalScale_bigDecimal() { } @Test - public void noDecimalScale_bigInteger() { + void noDecimalScale_bigInteger() { assertThatThrownBy( () -> setupHelper.start() .withIndex( StubMappedIndex.ofNonRetrievable( root -> root.field( "noScaled", f -> f.asBigInteger() ).toReference() @@ -73,7 +73,7 @@ public void noDecimalScale_bigInteger() { } @Test - public void positiveDecimalScale_bigInteger() { + void positiveDecimalScale_bigInteger() { assertThatThrownBy( () -> setupHelper.start() .withIndex( StubMappedIndex.ofNonRetrievable( root -> root.field( "positiveScaled", f -> f.asBigInteger().decimalScale( 3 ) ).toReference() @@ -86,7 +86,7 @@ public void positiveDecimalScale_bigInteger() { } @Test - public void decimalScale_bigDecimal() { + void decimalScale_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 3 ) ); @@ -101,7 +101,7 @@ public void decimalScale_bigDecimal() { } @Test - public void decimalScale_zeroScale_bigDecimal() { + void decimalScale_zeroScale_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 0 ) ); @@ -116,7 +116,7 @@ public void decimalScale_zeroScale_bigDecimal() { } @Test - public void decimalScale_zeroScale_bigInteger() { + void decimalScale_zeroScale_bigInteger() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, 0 ) ); @@ -131,7 +131,7 @@ public void decimalScale_zeroScale_bigInteger() { } @Test - public void decimalScale_negativeScale_bigDecimal() { + void decimalScale_negativeScale_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, -3 ) ); @@ -146,7 +146,7 @@ public void decimalScale_negativeScale_bigDecimal() { } @Test - public void decimalScale_negativeScale_bigInteger() { + void decimalScale_negativeScale_bigInteger() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, -3 ) ); @@ -161,7 +161,7 @@ public void decimalScale_negativeScale_bigInteger() { } @Test - public void decimalScale_largeScale_bigDecimal() { + void decimalScale_largeScale_bigDecimal() { final int schemaDecimalScale = 275; SimpleMappedIndex index = SimpleMappedIndex.of( @@ -199,7 +199,7 @@ public void decimalScale_largeScale_bigDecimal() { } @Test - public void decimalScale_negativeScale_largeScale_bigDecimal() { + void decimalScale_negativeScale_largeScale_bigDecimal() { final int schemaDecimalScale = -275; SimpleMappedIndex index = SimpleMappedIndex.of( @@ -237,7 +237,7 @@ public void decimalScale_negativeScale_largeScale_bigDecimal() { } @Test - public void decimalScale_negativeScale_largeScale_bigInteger() { + void decimalScale_negativeScale_largeScale_bigInteger() { final int schemaDecimalScale = -275; SimpleMappedIndex index = SimpleMappedIndex.of( @@ -276,7 +276,7 @@ public void decimalScale_negativeScale_largeScale_bigInteger() { } @Test - public void decimalScale_rounding_bigDecimal() { + void decimalScale_rounding_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 2 ) ); @@ -299,7 +299,7 @@ public void decimalScale_rounding_bigDecimal() { } @Test - public void decimalScale_rounding_bigInteger() { + void decimalScale_rounding_bigInteger() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, -4 ) ); @@ -322,7 +322,7 @@ public void decimalScale_rounding_bigInteger() { } @Test - public void decimalScale_largeDecimal_bigDecimal() { + void decimalScale_largeDecimal_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 0 ) ); @@ -342,7 +342,7 @@ public void decimalScale_largeDecimal_bigDecimal() { } @Test - public void decimalScale_largeDecimal_bigInteger() { + void decimalScale_largeDecimal_bigInteger() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, 0 ) ); @@ -362,7 +362,7 @@ public void decimalScale_largeDecimal_bigInteger() { } @Test - public void decimalScale_tooLargeDecimal_scale0_bigDecimal() { + void decimalScale_tooLargeDecimal_scale0_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 0 ) ); @@ -382,7 +382,7 @@ public void decimalScale_tooLargeDecimal_scale0_bigDecimal() { } @Test - public void decimalScale_tooLargeDecimal_scale0_bigDecimal_queryPredicateBuildTime() { + void decimalScale_tooLargeDecimal_scale0_bigDecimal_queryPredicateBuildTime() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 0 ) ); @@ -408,7 +408,7 @@ public void decimalScale_tooLargeDecimal_scale0_bigDecimal_queryPredicateBuildTi } @Test - public void decimalScale_tooLargeDecimal_scale0_bigDecimal_lowerBound() { + void decimalScale_tooLargeDecimal_scale0_bigDecimal_lowerBound() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 0 ) ); @@ -428,7 +428,7 @@ public void decimalScale_tooLargeDecimal_scale0_bigDecimal_lowerBound() { } @Test - public void decimalScale_tooLargeDecimal_scale0_bigInteger() { + void decimalScale_tooLargeDecimal_scale0_bigInteger() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, 0 ) ); @@ -448,7 +448,7 @@ public void decimalScale_tooLargeDecimal_scale0_bigInteger() { } @Test - public void decimalScale_tooLargeDecimal_scale0_bigInteger_lowerBound() { + void decimalScale_tooLargeDecimal_scale0_bigInteger_lowerBound() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, 0 ) ); @@ -468,7 +468,7 @@ public void decimalScale_tooLargeDecimal_scale0_bigInteger_lowerBound() { } @Test - public void decimalScale_tooLargeDecimal_scale0_bigInteger_lowerBound_queryPredicateBuildTime() { + void decimalScale_tooLargeDecimal_scale0_bigInteger_lowerBound_queryPredicateBuildTime() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, 0 ) ); @@ -494,7 +494,7 @@ public void decimalScale_tooLargeDecimal_scale0_bigInteger_lowerBound_queryPredi } @Test - public void decimalScale_tooLargeDecimal_scale2_bigDecimal() { + void decimalScale_tooLargeDecimal_scale2_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 2 ) ); @@ -514,7 +514,7 @@ public void decimalScale_tooLargeDecimal_scale2_bigDecimal() { } @Test - public void decimalScale_tooLargeDecimal_scale2_bigDecimal_lowerBound() { + void decimalScale_tooLargeDecimal_scale2_bigDecimal_lowerBound() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 2 ) ); @@ -534,7 +534,7 @@ public void decimalScale_tooLargeDecimal_scale2_bigDecimal_lowerBound() { } @Test - public void decimalScale_tooLargeDecimal_scale2_bigDecimal_lowerBound_queryPredicateBuildTime() { + void decimalScale_tooLargeDecimal_scale2_bigDecimal_lowerBound_queryPredicateBuildTime() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 2 ) ); @@ -560,7 +560,7 @@ public void decimalScale_tooLargeDecimal_scale2_bigDecimal_lowerBound_queryPredi } @Test - public void decimalScale_tooLargeDecimal_scaleMinus2_bigInteger() { + void decimalScale_tooLargeDecimal_scaleMinus2_bigInteger() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, -2 ) ); @@ -580,7 +580,7 @@ public void decimalScale_tooLargeDecimal_scaleMinus2_bigInteger() { } @Test - public void decimalScale_tooLargeDecimal_scaleMinus2_bigInteger_queryPredicateBuildTime() { + void decimalScale_tooLargeDecimal_scaleMinus2_bigInteger_queryPredicateBuildTime() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, -2 ) ); @@ -606,7 +606,7 @@ public void decimalScale_tooLargeDecimal_scaleMinus2_bigInteger_queryPredicateBu } @Test - public void decimalScale_tooLargeDecimal_scaleMinus2_bigInteger_lowerBound() { + void decimalScale_tooLargeDecimal_scaleMinus2_bigInteger_lowerBound() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, -2 ) ); @@ -626,7 +626,7 @@ public void decimalScale_tooLargeDecimal_scaleMinus2_bigInteger_lowerBound() { } @Test - public void defaultDecimalScale_bigDecimal() { + void defaultDecimalScale_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.ofAdvanced( DefaultDecimalScaleIndexBinding::new ); @@ -643,7 +643,7 @@ public void defaultDecimalScale_bigDecimal() { } @Test - public void defaultDecimalScale_bigInteger() { + void defaultDecimalScale_bigInteger() { SimpleMappedIndex index = SimpleMappedIndex.ofAdvanced( DefaultIntegerScaleIndexBinding::new ); @@ -660,7 +660,7 @@ public void defaultDecimalScale_bigInteger() { } @Test - public void decimalScale_andDefaultDecimalScale_bigDecimal() { + void decimalScale_andDefaultDecimalScale_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.ofAdvanced( BothDecimalScaleIndexBinding::new ); @@ -678,7 +678,7 @@ public void decimalScale_andDefaultDecimalScale_bigDecimal() { } @Test - public void decimalScale_andDefaultDecimalScale_bigInteger() { + void decimalScale_andDefaultDecimalScale_bigInteger() { SimpleMappedIndex index = SimpleMappedIndex.ofAdvanced( BothIntegerScaleIndexBinding::new ); @@ -696,7 +696,7 @@ public void decimalScale_andDefaultDecimalScale_bigInteger() { } @Test - public void decimalScale_doesNotAffectProjections_bigDecimal() { + void decimalScale_doesNotAffectProjections_bigDecimal() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new DecimalScaleIndexBinding( root, 3 ) ); @@ -711,7 +711,7 @@ public void decimalScale_doesNotAffectProjections_bigDecimal() { } @Test - public void decimalScale_doesNotAffectProjections_bigInteger() { + void decimalScale_doesNotAffectProjections_bigInteger() { SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IntegerScaleIndexBinding( root, -7 ) ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementDynamicFieldNameIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementDynamicFieldNameIT.java index 5ace80d93e0..441c65f8482 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementDynamicFieldNameIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementDynamicFieldNameIT.java @@ -11,6 +11,7 @@ import java.util.Collections; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; import org.hibernate.search.engine.backend.document.DocumentElement; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; @@ -18,68 +19,64 @@ import org.hibernate.search.engine.common.tree.TreeFilterDefinition; import org.hibernate.search.engine.mapper.mapping.building.spi.IndexedEntityBindingContext; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingElement; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test the basic behavior of implementations of {@link DocumentElement} * when referencing dynamic fields using their name. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3273") -public class DocumentElementDynamicFieldNameIT { +class DocumentElementDynamicFieldNameIT { private static List> supportedTypeDescriptors() { return FieldTypeDescriptor.getAll(); } - @Parameterized.Parameters(name = "{0}") - public static List> parameters() { - return supportedTypeDescriptors(); + public static List params() { + return supportedTypeDescriptors().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.ofAdvanced( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldType; - - public DocumentElementDynamicFieldNameIT(FieldTypeDescriptor fieldType) { - this.fieldType = fieldType; - } - /** * Test that DocumentElement.addValue does not throw any exception when passing a non-null value. */ - @Test - public void addValue_nonNull() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_nonNull(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNonNullValue( document ); + setNonNullValue( document, fieldType ); } ); } /** * Test that DocumentElement.addValue does not throw any exception when passing a null value. */ - @Test - public void addValue_null() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_null(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNullValue( document ); + setNullValue( document, fieldType ); } ); } @@ -87,40 +84,42 @@ public void addValue_null() { * Test that DocumentElement.addObject does not throw any exception, * add that DocumentElement.addValue does not throw an exception for returned objects. */ - @Test - public void addObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addObject(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNullValue( document ); + setNullValue( document, fieldType ); DocumentElement flattenedObject = document.addObject( "flattenedObject" ); - setNonNullValue( flattenedObject ); + setNonNullValue( flattenedObject, fieldType ); flattenedObject = document.addObject( "flattenedObject" ); - setNullValue( flattenedObject ); + setNullValue( flattenedObject, fieldType ); DocumentElement flattenedObjectSecondLevelObject = flattenedObject.addObject( "flattenedObject" ); - setNonNullValue( flattenedObjectSecondLevelObject ); + setNonNullValue( flattenedObjectSecondLevelObject, fieldType ); flattenedObjectSecondLevelObject = flattenedObject.addObject( "nestedObject" ); - setNullValue( flattenedObjectSecondLevelObject ); + setNullValue( flattenedObjectSecondLevelObject, fieldType ); DocumentElement nestedObject = document.addObject( "nestedObject" ); - setNonNullValue( nestedObject ); + setNonNullValue( nestedObject, fieldType ); nestedObject = document.addObject( "nestedObject" ); - setNullValue( nestedObject ); + setNullValue( nestedObject, fieldType ); DocumentElement nestedObjectSecondLevelObject = nestedObject.addObject( "flattenedObject" ); - setNonNullValue( nestedObjectSecondLevelObject ); + setNonNullValue( nestedObjectSecondLevelObject, fieldType ); nestedObjectSecondLevelObject = nestedObject.addObject( "nestedObject" ); - setNullValue( nestedObjectSecondLevelObject ); + setNullValue( nestedObjectSecondLevelObject, fieldType ); } ); } /** * Test that DocumentElement.addNullObject does not throw any exception. */ - @Test - public void addNullObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addNullObject(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNullValue( document ); + setNullValue( document, fieldType ); DocumentElement flattenedObject = document.addObject( "flattenedObject" ); document.addNullObject( "flattenedObject" ); @@ -143,29 +142,31 @@ public void addNullObject() { * adding a value to a dynamic field on an object field that excludes all static children * (due to IndexedEmbedded filters). */ - @Test - public void add_excludedFields() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void add_excludedFields(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { DocumentElement excludingObject = document.addObject( "excludingObject" ); - setNonNullValue( excludingObject ); + setNonNullValue( excludingObject, fieldType ); excludingObject = document.addObject( "excludingObject" ); - setNullValue( excludingObject ); + setNullValue( excludingObject, fieldType ); DocumentElement flattenedSecondLevelObject = excludingObject.addObject( "flattenedObject" ); - setNonNullValue( flattenedSecondLevelObject ); + setNonNullValue( flattenedSecondLevelObject, fieldType ); flattenedSecondLevelObject = excludingObject.addObject( "flattenedObject" ); - setNullValue( flattenedSecondLevelObject ); + setNullValue( flattenedSecondLevelObject, fieldType ); DocumentElement nestedSecondLevelObject = excludingObject.addObject( "nestedObject" ); - setNullValue( nestedSecondLevelObject ); + setNullValue( nestedSecondLevelObject, fieldType ); nestedSecondLevelObject = excludingObject.addObject( "nestedObject" ); - setNullValue( nestedSecondLevelObject ); + setNullValue( nestedSecondLevelObject, fieldType ); } ); } - @Test - public void addValue_unknownField() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_unknownField(FieldTypeDescriptor fieldType) { assertThatThrownBy( () -> executeAdd( "1", document -> { document.addValue( "unknownField", null ); } ) ) @@ -176,8 +177,9 @@ public void addValue_unknownField() { ); } - @Test - public void addObject_unknownField() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addObject_unknownField(FieldTypeDescriptor fieldType) { assertThatThrownBy( () -> executeAdd( "1", document -> { document.addObject( "unknownField" ); } ) ) @@ -188,8 +190,9 @@ public void addObject_unknownField() { ); } - @Test - public void addNullObject_unknownField() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addNullObject_unknownField(FieldTypeDescriptor fieldType) { assertThatThrownBy( () -> executeAdd( "1", document -> { document.addNullObject( "unknownField" ); } ) ) @@ -200,12 +203,13 @@ public void addNullObject_unknownField() { ); } - @Test - public void addValue_invalidType() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_invalidType(FieldTypeDescriptor fieldType) { FieldTypeDescriptor invalidType = FieldTypeDescriptor.getIncompatible( fieldType ); Object valueWithInvalidType = invalidType.getIndexableValues().getSingle().get( 0 ); - String relativeFieldName = getRelativeFieldName(); + String relativeFieldName = getRelativeFieldName( fieldType ); assertThatThrownBy( () -> executeAdd( "1", document -> { document.addValue( relativeFieldName, valueWithInvalidType ); @@ -219,19 +223,19 @@ public void addValue_invalidType() { ); } - private void setNonNullValue(DocumentElement document) { - document.addValue( getRelativeFieldName(), fieldType.getIndexableValues().getSingle().get( 0 ) ); + private void setNonNullValue(DocumentElement document, FieldTypeDescriptor fieldType) { + document.addValue( getRelativeFieldName( fieldType ), fieldType.getIndexableValues().getSingle().get( 0 ) ); } - private void setNullValue(DocumentElement document) { - document.addValue( getRelativeFieldName(), null ); + private void setNullValue(DocumentElement document, FieldTypeDescriptor fieldType) { + document.addValue( getRelativeFieldName( fieldType ), null ); } private void executeAdd(String id, Consumer documentContributor) { index.index( id, documentContributor::accept ); } - private String getRelativeFieldName() { + private String getRelativeFieldName(FieldTypeDescriptor fieldType) { // Matches the template defined in IndexBinding return "foo_" + fieldType.getUniqueName(); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementFieldReferenceIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementFieldReferenceIT.java index 8e78991f4d7..aff789c0f95 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementFieldReferenceIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementFieldReferenceIT.java @@ -11,6 +11,7 @@ import java.util.Collections; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; import org.hibernate.search.engine.backend.document.DocumentElement; import org.hibernate.search.engine.backend.document.IndexFieldReference; @@ -23,66 +24,62 @@ import org.hibernate.search.engine.mapper.mapping.building.spi.IndexedEntityBindingContext; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingElement; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test the basic behavior of implementations of {@link DocumentElement} * when referencing fields using a {@link IndexFieldReference}. */ -@RunWith(Parameterized.class) -public class DocumentElementFieldReferenceIT { +class DocumentElementFieldReferenceIT { private static List> supportedTypeDescriptors() { return FieldTypeDescriptor.getAll(); } - @Parameterized.Parameters(name = "{0}") - public static List> parameters() { - return supportedTypeDescriptors(); + public static List params() { + return supportedTypeDescriptors().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.ofAdvanced( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldType; - - public DocumentElementFieldReferenceIT(FieldTypeDescriptor fieldType) { - this.fieldType = fieldType; - } - /** * Test that DocumentElement.addValue does not throw any exception when passing a non-null value. */ - @Test - public void addValue_nonNull() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_nonNull(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNonNullValue( index.binding(), document ); + setNonNullValue( index.binding(), document, fieldType ); } ); } /** * Test that DocumentElement.addValue does not throw any exception when passing a null value. */ - @Test - public void addValue_null() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_null(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNullValue( index.binding(), document ); + setNullValue( index.binding(), document, fieldType ); } ); } @@ -90,40 +87,44 @@ public void addValue_null() { * Test that DocumentElement.addObject does not throw any exception, * add that DocumentElement.addValue does not throw an exception for returned objects. */ - @Test - public void addObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addObject(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNullValue( index.binding(), document ); + setNullValue( index.binding(), document, fieldType ); DocumentElement flattenedObject = document.addObject( index.binding().flattenedObject.self ); - setNonNullValue( index.binding().flattenedObject, flattenedObject ); + setNonNullValue( index.binding().flattenedObject, flattenedObject, fieldType ); flattenedObject = document.addObject( index.binding().flattenedObject.self ); - setNullValue( index.binding().flattenedObject, flattenedObject ); + setNullValue( index.binding().flattenedObject, flattenedObject, fieldType ); DocumentElement flattenedObjectSecondLevelObject = flattenedObject.addObject( index.binding().flattenedObject.flattenedObject.self ); - setNonNullValue( index.binding().flattenedObject.flattenedObject, flattenedObjectSecondLevelObject ); + setNonNullValue( index.binding().flattenedObject.flattenedObject, flattenedObjectSecondLevelObject, + fieldType + ); flattenedObjectSecondLevelObject = flattenedObject.addObject( index.binding().flattenedObject.nestedObject.self ); - setNullValue( index.binding().flattenedObject.nestedObject, flattenedObjectSecondLevelObject ); + setNullValue( index.binding().flattenedObject.nestedObject, flattenedObjectSecondLevelObject, fieldType ); DocumentElement nestedObject = document.addObject( index.binding().nestedObject.self ); - setNonNullValue( index.binding().nestedObject, nestedObject ); + setNonNullValue( index.binding().nestedObject, nestedObject, fieldType ); nestedObject = document.addObject( index.binding().nestedObject.self ); - setNullValue( index.binding().nestedObject, nestedObject ); + setNullValue( index.binding().nestedObject, nestedObject, fieldType ); DocumentElement nestedObjectSecondLevelObject = nestedObject.addObject( index.binding().nestedObject.flattenedObject.self ); - setNonNullValue( index.binding().nestedObject.flattenedObject, nestedObjectSecondLevelObject ); + setNonNullValue( index.binding().nestedObject.flattenedObject, nestedObjectSecondLevelObject, fieldType ); nestedObjectSecondLevelObject = nestedObject.addObject( index.binding().nestedObject.nestedObject.self ); - setNullValue( index.binding().nestedObject.nestedObject, nestedObjectSecondLevelObject ); + setNullValue( index.binding().nestedObject.nestedObject, nestedObjectSecondLevelObject, fieldType ); } ); } /** * Test that DocumentElement.addNullObject does not throw any exception. */ - @Test - public void addNullObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addNullObject(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNullValue( index.binding(), document ); + setNullValue( index.binding(), document, fieldType ); DocumentElement flattenedObject = document.addObject( index.binding().flattenedObject.self ); document.addNullObject( index.binding().flattenedObject.self ); @@ -146,30 +147,32 @@ public void addNullObject() { * adding a value to a static field on an object field that excludes all static children * (due to IndexedEmbedded filters). */ - @Test - public void addValue_excludedFields() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_excludedFields(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { DocumentElement excludingObject = document.addObject( index.binding().excludingObject.self ); - setNonNullValue( index.binding().excludingObject, excludingObject ); + setNonNullValue( index.binding().excludingObject, excludingObject, fieldType ); excludingObject = document.addObject( index.binding().excludingObject.self ); - setNullValue( index.binding().excludingObject, excludingObject ); + setNullValue( index.binding().excludingObject, excludingObject, fieldType ); DocumentElement flattenedSecondLevelObject = excludingObject.addObject( index.binding().excludingObject.flattenedObject.self ); - setNonNullValue( index.binding().excludingObject.flattenedObject, flattenedSecondLevelObject ); + setNonNullValue( index.binding().excludingObject.flattenedObject, flattenedSecondLevelObject, fieldType ); flattenedSecondLevelObject = excludingObject.addObject( index.binding().excludingObject.flattenedObject.self ); - setNullValue( index.binding().excludingObject.flattenedObject, flattenedSecondLevelObject ); + setNullValue( index.binding().excludingObject.flattenedObject, flattenedSecondLevelObject, fieldType ); DocumentElement nestedSecondLevelObject = excludingObject.addObject( index.binding().excludingObject.nestedObject.self ); - setNullValue( index.binding().excludingObject.nestedObject, nestedSecondLevelObject ); + setNullValue( index.binding().excludingObject.nestedObject, nestedSecondLevelObject, fieldType ); nestedSecondLevelObject = excludingObject.addObject( index.binding().excludingObject.nestedObject.self ); - setNullValue( index.binding().excludingObject.nestedObject, nestedSecondLevelObject ); + setNullValue( index.binding().excludingObject.nestedObject, nestedSecondLevelObject, fieldType ); } ); } - @Test - public void invalidFieldForDocumentElement_flattenedObjectChild() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidFieldForDocumentElement_flattenedObjectChild(FieldTypeDescriptor fieldType) { IndexFieldReference reference = index.binding().flattenedObject.fieldModels.get( fieldType ).reference; assertThatThrownBy( () -> executeAdd( "1", document -> { @@ -183,8 +186,9 @@ public void invalidFieldForDocumentElement_flattenedObjectChild() { .hasMessageContaining( "but the referenced field has a parent with path 'null'" ); } - @Test - public void invalidFieldForDocumentElement_nestedObjectChild() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidFieldForDocumentElement_nestedObjectChild(FieldTypeDescriptor fieldType) { IndexFieldReference reference = index.binding().nestedObject.fieldModels.get( fieldType ).reference; assertThatThrownBy( () -> executeAdd( "1", document -> { @@ -198,8 +202,9 @@ public void invalidFieldForDocumentElement_nestedObjectChild() { .hasMessageContaining( "but the referenced field has a parent with path 'null'" ); } - @Test - public void invalidFieldForDocumentElement_rootChild() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidFieldForDocumentElement_rootChild(FieldTypeDescriptor fieldType) { IndexFieldReference reference = index.binding().fieldModels.get( fieldType ).reference; assertThatThrownBy( () -> executeAdd( "1", document -> { @@ -214,12 +219,14 @@ public void invalidFieldForDocumentElement_rootChild() { .hasMessageContaining( "but the referenced field has a parent with path 'flattenedObject'" ); } - private void setNonNullValue(AbstractObjectBinding binding, DocumentElement document) { + private void setNonNullValue(AbstractObjectBinding binding, DocumentElement document, + FieldTypeDescriptor fieldType) { document.addValue( binding.fieldModels.get( fieldType ).reference, fieldType.getIndexableValues().getSingle().get( 0 ) ); } - private void setNullValue(AbstractObjectBinding binding, DocumentElement document) { + private void setNullValue(AbstractObjectBinding binding, DocumentElement document, + FieldTypeDescriptor fieldType) { document.addValue( binding.fieldModels.get( fieldType ).reference, null ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementMultiValuedIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementMultiValuedIT.java index 775be6ba16e..de40c6ecf6a 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementMultiValuedIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementMultiValuedIT.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; import org.hibernate.search.engine.backend.document.DocumentElement; import org.hibernate.search.engine.backend.document.IndexObjectFieldReference; @@ -19,71 +20,67 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test the behavior of implementations of {@link DocumentElement} * when it comes to multi-valued fields. */ -@RunWith(Parameterized.class) -public class DocumentElementMultiValuedIT { +class DocumentElementMultiValuedIT { private static List> supportedTypeDescriptors() { return FieldTypeDescriptor.getAll(); } - @Parameterized.Parameters(name = "{0}") - public static List> parameters() { - return supportedTypeDescriptors(); + public static List params() { + return supportedTypeDescriptors().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldType; - - public DocumentElementMultiValuedIT(FieldTypeDescriptor fieldType) { - this.fieldType = fieldType; - } - - @Test - public void addValue_root() { - SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding() ); - SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding() ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_root(FieldTypeDescriptor fieldType) { + SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding(), fieldType ); + SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding(), fieldType ); expectSuccess( "1", document -> { - document.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); + document.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSingleValuedException( "2", singleValuedFieldModel.relativeFieldName, document -> { - document.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); - document.addValue( singleValuedFieldModel.reference, getValue( 1 ) ); + document.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); + document.addValue( singleValuedFieldModel.reference, getValue( 1, fieldType ) ); } ); expectSuccess( "3", document -> { - document.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + document.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSuccess( "4", document -> { - document.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); - document.addValue( multiValuedFieldModel.reference, getValue( 1 ) ); - document.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + document.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); + document.addValue( multiValuedFieldModel.reference, getValue( 1, fieldType ) ); + document.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); } - @Test - public void addObject_flattened() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addObject_flattened(FieldTypeDescriptor fieldType) { expectSuccess( "1", document -> { document.addObject( index.binding().singleValuedFlattenedObject.self ); } ); @@ -101,8 +98,9 @@ public void addObject_flattened() { } ); } - @Test - public void addObject_nested() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addObject_nested(FieldTypeDescriptor fieldType) { expectSuccess( "1", document -> { document.addObject( index.binding().singleValuedNestedObject.self ); } ); @@ -120,8 +118,9 @@ public void addObject_nested() { } ); } - @Test - public void addNullObject_flattened() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addNullObject_flattened(FieldTypeDescriptor fieldType) { expectSuccess( "1", document -> { document.addObject( index.binding().singleValuedFlattenedObject.self ); } ); @@ -157,8 +156,9 @@ public void addNullObject_flattened() { } ); } - @Test - public void addNullObject_nested() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addNullObject_nested(FieldTypeDescriptor fieldType) { expectSuccess( "1", document -> { document.addObject( index.binding().singleValuedNestedObject.self ); } ); @@ -194,105 +194,125 @@ public void addNullObject_nested() { } ); } - @Test - public void addValue_inSingleValuedFlattenedObject() { - SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding().singleValuedFlattenedObject ); - SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding().singleValuedFlattenedObject ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_inSingleValuedFlattenedObject(FieldTypeDescriptor fieldType) { + SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding().singleValuedFlattenedObject, + fieldType + ); + SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding().singleValuedFlattenedObject, + fieldType + ); expectSuccess( "1", document -> { DocumentElement level1 = document.addObject( index.binding().singleValuedFlattenedObject.self ); - level1.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSingleValuedException( "2", "singleValuedFlattenedObject." + singleValuedFieldModel.relativeFieldName, document -> { DocumentElement level1 = document.addObject( index.binding().singleValuedFlattenedObject.self ); - level1.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); - level1.addValue( singleValuedFieldModel.reference, getValue( 1 ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 1, fieldType ) ); } ); expectSuccess( "3", document -> { DocumentElement level1 = document.addObject( index.binding().singleValuedFlattenedObject.self ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSuccess( "4", document -> { DocumentElement level1 = document.addObject( index.binding().singleValuedFlattenedObject.self ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); - level1.addValue( multiValuedFieldModel.reference, getValue( 1 ) ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 1, fieldType ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); } - @Test - public void addValue_inMultiValuedFlattenedObject() { - SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding().multiValuedFlattenedObject ); - SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding().multiValuedFlattenedObject ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_inMultiValuedFlattenedObject(FieldTypeDescriptor fieldType) { + SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding().multiValuedFlattenedObject, + fieldType + ); + SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding().multiValuedFlattenedObject, + fieldType + ); expectSuccess( "1", document -> { DocumentElement level1 = document.addObject( index.binding().multiValuedFlattenedObject.self ); - level1.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSingleValuedException( "2", "multiValuedFlattenedObject." + singleValuedFieldModel.relativeFieldName, document -> { DocumentElement level1 = document.addObject( index.binding().multiValuedFlattenedObject.self ); - level1.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); - level1.addValue( singleValuedFieldModel.reference, getValue( 1 ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 1, fieldType ) ); } ); expectSuccess( "3", document -> { DocumentElement level1 = document.addObject( index.binding().multiValuedFlattenedObject.self ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSuccess( "4", document -> { DocumentElement level1 = document.addObject( index.binding().multiValuedFlattenedObject.self ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); - level1.addValue( multiValuedFieldModel.reference, getValue( 1 ) ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 1, fieldType ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); } - @Test - public void addValue_inSingleValuedNestedObject() { - SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding().singleValuedNestedObject ); - SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding().singleValuedNestedObject ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_inSingleValuedNestedObject(FieldTypeDescriptor fieldType) { + SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding().singleValuedNestedObject, + fieldType + ); + SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding().singleValuedNestedObject, + fieldType + ); expectSuccess( "1", document -> { DocumentElement level1 = document.addObject( index.binding().singleValuedNestedObject.self ); - level1.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSingleValuedException( "2", "singleValuedNestedObject." + singleValuedFieldModel.relativeFieldName, document -> { DocumentElement level1 = document.addObject( index.binding().singleValuedNestedObject.self ); - level1.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); - level1.addValue( singleValuedFieldModel.reference, getValue( 1 ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 1, fieldType ) ); } ); expectSuccess( "3", document -> { DocumentElement level1 = document.addObject( index.binding().singleValuedNestedObject.self ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSuccess( "4", document -> { DocumentElement level1 = document.addObject( index.binding().singleValuedNestedObject.self ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); - level1.addValue( multiValuedFieldModel.reference, getValue( 1 ) ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 1, fieldType ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); } - @Test - public void addValue_inMultiValuedNestedObject() { - SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding().multiValuedNestedObject ); - SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding().multiValuedNestedObject ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_inMultiValuedNestedObject(FieldTypeDescriptor fieldType) { + SimpleFieldModel singleValuedFieldModel = getSingleValuedField( index.binding().multiValuedNestedObject, + fieldType + ); + SimpleFieldModel multiValuedFieldModel = getMultiValuedField( index.binding().multiValuedNestedObject, + fieldType + ); expectSuccess( "1", document -> { DocumentElement level1 = document.addObject( index.binding().multiValuedNestedObject.self ); - level1.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSingleValuedException( "2", "multiValuedNestedObject." + singleValuedFieldModel.relativeFieldName, document -> { DocumentElement level1 = document.addObject( index.binding().multiValuedNestedObject.self ); - level1.addValue( singleValuedFieldModel.reference, getValue( 0 ) ); - level1.addValue( singleValuedFieldModel.reference, getValue( 1 ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 0, fieldType ) ); + level1.addValue( singleValuedFieldModel.reference, getValue( 1, fieldType ) ); } ); expectSuccess( "3", document -> { DocumentElement level1 = document.addObject( index.binding().multiValuedNestedObject.self ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); expectSuccess( "4", document -> { DocumentElement level1 = document.addObject( index.binding().multiValuedNestedObject.self ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); - level1.addValue( multiValuedFieldModel.reference, getValue( 1 ) ); - level1.addValue( multiValuedFieldModel.reference, getValue( 0 ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 1, fieldType ) ); + level1.addValue( multiValuedFieldModel.reference, getValue( 0, fieldType ) ); } ); } @@ -318,15 +338,15 @@ private void executeAdd(String id, Consumer documentContributor index.index( id, documentContributor::accept ); } - private F getValue(int ordinal) { + private F getValue(int ordinal, FieldTypeDescriptor fieldType) { return fieldType.getIndexableValues().getSingle().get( ordinal ); } - private SimpleFieldModel getSingleValuedField(AbstractObjectBinding binding) { + private SimpleFieldModel getSingleValuedField(AbstractObjectBinding binding, FieldTypeDescriptor fieldType) { return binding.singleValuedFieldModels.get( fieldType ); } - private SimpleFieldModel getMultiValuedField(AbstractObjectBinding binding) { + private SimpleFieldModel getMultiValuedField(AbstractObjectBinding binding, FieldTypeDescriptor fieldType) { return binding.multiValuedFieldModels.get( fieldType ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementStaticFieldNameIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementStaticFieldNameIT.java index a366de781c7..9ad7b668d2d 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementStaticFieldNameIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/DocumentElementStaticFieldNameIT.java @@ -11,6 +11,7 @@ import java.util.Collections; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; import org.hibernate.search.engine.backend.document.DocumentElement; import org.hibernate.search.engine.backend.document.IndexObjectFieldReference; @@ -23,68 +24,64 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingElement; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test the basic behavior of implementations of {@link DocumentElement} * when referencing static fields using their name. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3273") -public class DocumentElementStaticFieldNameIT { +class DocumentElementStaticFieldNameIT { private static List> supportedTypeDescriptors() { return FieldTypeDescriptor.getAll(); } - @Parameterized.Parameters(name = "{0}") - public static List> parameters() { - return supportedTypeDescriptors(); + public static List params() { + return supportedTypeDescriptors().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.ofAdvanced( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldType; - - public DocumentElementStaticFieldNameIT(FieldTypeDescriptor fieldType) { - this.fieldType = fieldType; - } - /** * Test that DocumentElement.addValue does not throw any exception when passing a non-null value. */ - @Test - public void addValue_nonNull() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_nonNull(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNonNullValue( document ); + setNonNullValue( document, fieldType ); } ); } /** * Test that DocumentElement.addValue does not throw any exception when passing a null value. */ - @Test - public void addValue_null() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_null(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNullValue( document ); + setNullValue( document, fieldType ); } ); } @@ -92,40 +89,42 @@ public void addValue_null() { * Test that DocumentElement.addObject does not throw any exception, * add that DocumentElement.addValue does not throw an exception for returned objects. */ - @Test - public void addObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addObject(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNullValue( document ); + setNullValue( document, fieldType ); DocumentElement flattenedObject = document.addObject( "flattenedObject" ); - setNonNullValue( flattenedObject ); + setNonNullValue( flattenedObject, fieldType ); flattenedObject = document.addObject( "flattenedObject" ); - setNullValue( flattenedObject ); + setNullValue( flattenedObject, fieldType ); DocumentElement flattenedObjectSecondLevelObject = flattenedObject.addObject( "flattenedObject" ); - setNonNullValue( flattenedObjectSecondLevelObject ); + setNonNullValue( flattenedObjectSecondLevelObject, fieldType ); flattenedObjectSecondLevelObject = flattenedObject.addObject( "nestedObject" ); - setNullValue( flattenedObjectSecondLevelObject ); + setNullValue( flattenedObjectSecondLevelObject, fieldType ); DocumentElement nestedObject = document.addObject( "nestedObject" ); - setNonNullValue( nestedObject ); + setNonNullValue( nestedObject, fieldType ); nestedObject = document.addObject( "nestedObject" ); - setNullValue( nestedObject ); + setNullValue( nestedObject, fieldType ); DocumentElement nestedObjectSecondLevelObject = nestedObject.addObject( "flattenedObject" ); - setNonNullValue( nestedObjectSecondLevelObject ); + setNonNullValue( nestedObjectSecondLevelObject, fieldType ); nestedObjectSecondLevelObject = nestedObject.addObject( "nestedObject" ); - setNullValue( nestedObjectSecondLevelObject ); + setNullValue( nestedObjectSecondLevelObject, fieldType ); } ); } /** * Test that DocumentElement.addNullObject does not throw any exception. */ - @Test - public void addNullObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addNullObject(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { - setNullValue( document ); + setNullValue( document, fieldType ); DocumentElement flattenedObject = document.addObject( "flattenedObject" ); document.addNullObject( "flattenedObject" ); @@ -148,29 +147,31 @@ public void addNullObject() { * adding a value to a static field on an object field that excludes all static children * (due to IndexedEmbedded filters). */ - @Test - public void add_excludedFields() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void add_excludedFields(FieldTypeDescriptor fieldType) { executeAdd( "1", document -> { DocumentElement excludingObject = document.addObject( "excludingObject" ); - setNonNullValue( excludingObject ); + setNonNullValue( excludingObject, fieldType ); excludingObject = document.addObject( "excludingObject" ); - setNullValue( excludingObject ); + setNullValue( excludingObject, fieldType ); DocumentElement flattenedSecondLevelObject = excludingObject.addObject( "flattenedObject" ); - setNonNullValue( flattenedSecondLevelObject ); + setNonNullValue( flattenedSecondLevelObject, fieldType ); flattenedSecondLevelObject = excludingObject.addObject( "flattenedObject" ); - setNullValue( flattenedSecondLevelObject ); + setNullValue( flattenedSecondLevelObject, fieldType ); DocumentElement nestedSecondLevelObject = excludingObject.addObject( "nestedObject" ); - setNullValue( nestedSecondLevelObject ); + setNullValue( nestedSecondLevelObject, fieldType ); nestedSecondLevelObject = excludingObject.addObject( "nestedObject" ); - setNullValue( nestedSecondLevelObject ); + setNullValue( nestedSecondLevelObject, fieldType ); } ); } - @Test - public void addValue_unknownField() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_unknownField(FieldTypeDescriptor fieldType) { assertThatThrownBy( () -> executeAdd( "1", document -> { document.addValue( "unknownField", null ); } ) ) @@ -181,8 +182,9 @@ public void addValue_unknownField() { ); } - @Test - public void addObject_unknownField() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addObject_unknownField(FieldTypeDescriptor fieldType) { assertThatThrownBy( () -> executeAdd( "1", document -> { document.addObject( "unknownField" ); } ) ) @@ -193,8 +195,9 @@ public void addObject_unknownField() { ); } - @Test - public void addNullObject_unknownField() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addNullObject_unknownField(FieldTypeDescriptor fieldType) { assertThatThrownBy( () -> executeAdd( "1", document -> { document.addNullObject( "unknownField" ); } ) ) @@ -205,8 +208,9 @@ public void addNullObject_unknownField() { ); } - @Test - public void addValue_invalidValueType() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addValue_invalidValueType(FieldTypeDescriptor fieldType) { FieldTypeDescriptor invalidType = FieldTypeDescriptor.getIncompatible( fieldType ); Object valueWithInvalidType = invalidType.getIndexableValues().getSingle().get( 0 ); @@ -224,19 +228,19 @@ public void addValue_invalidValueType() { ); } - private void setNonNullValue(DocumentElement document) { - document.addValue( getRelativeFieldName(), fieldType.getIndexableValues().getSingle().get( 0 ) ); + private void setNonNullValue(DocumentElement document, FieldTypeDescriptor fieldType) { + document.addValue( getRelativeFieldName( fieldType ), fieldType.getIndexableValues().getSingle().get( 0 ) ); } - private void setNullValue(DocumentElement document) { - document.addValue( getRelativeFieldName(), null ); + private void setNullValue(DocumentElement document, FieldTypeDescriptor fieldType) { + document.addValue( getRelativeFieldName( fieldType ), null ); } private void executeAdd(String id, Consumer documentContributor) { index.index( id, documentContributor::accept ); } - private String getRelativeFieldName() { + private String getRelativeFieldName(FieldTypeDescriptor fieldType) { // Matches the name defined in AbstractObjectBinding return fieldType.getUniqueName(); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementFieldIT.java index af5cf07ea77..5a4d5f32450 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementFieldIT.java @@ -16,13 +16,13 @@ import org.hibernate.search.engine.backend.types.dsl.IndexFieldTypeFactory; import org.hibernate.search.engine.backend.types.dsl.IndexFieldTypeFinalStep; import org.hibernate.search.engine.mapper.mapping.building.spi.IndexBindingContext; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test the behavior of implementations of {@link IndexSchemaElement} when defining fields. @@ -31,15 +31,15 @@ * since this would require backend-specific code to inspect that schema. * However, in search and projection tests, we check that defined fields behave correctly at runtime. */ -public class IndexSchemaElementFieldIT { +class IndexSchemaElementFieldIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private StubMappedIndex index; @Test - public void nullFieldName() { + void nullFieldName() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -100,7 +100,7 @@ public void nullFieldName() { } @Test - public void emptyFieldName() { + void emptyFieldName() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -159,7 +159,7 @@ public void emptyFieldName() { } @Test - public void dotInFieldName() { + void dotInFieldName() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -238,7 +238,7 @@ public void dotInFieldName() { } @Test - public void nameCollision_fields() { + void nameCollision_fields() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -273,7 +273,7 @@ public void nameCollision_fields() { } @Test - public void nameCollision_objectFields() { + void nameCollision_objectFields() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -308,7 +308,7 @@ public void nameCollision_objectFields() { } @Test - public void nameCollision_fieldAndObjectField() { + void nameCollision_fieldAndObjectField() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -343,7 +343,7 @@ public void nameCollision_fieldAndObjectField() { } @Test - public void missingToReferenceCall() { + void missingToReferenceCall() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -373,7 +373,7 @@ public void missingToReferenceCall() { } @Test - public void multipleToReferenceCall() { + void multipleToReferenceCall() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementFieldTemplateIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementFieldTemplateIT.java index 5e5d56a7211..7d7f7fe7c7f 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementFieldTemplateIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementFieldTemplateIT.java @@ -15,13 +15,13 @@ import org.hibernate.search.engine.backend.types.dsl.IndexFieldTypeFactory; import org.hibernate.search.engine.backend.types.dsl.IndexFieldTypeFinalStep; import org.hibernate.search.engine.mapper.mapping.building.spi.IndexBindingContext; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test the behavior of implementations of {@link IndexSchemaElement} when defining field templates. @@ -30,15 +30,15 @@ * since this would require backend-specific code to inspect that schema. * However, in search and projection tests, we check that defined fields behave correctly at runtime. */ -public class IndexSchemaElementFieldTemplateIT { +class IndexSchemaElementFieldTemplateIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private StubMappedIndex index; @Test - public void nullName() { + void nullName() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -94,7 +94,7 @@ public void nullName() { } @Test - public void emptyName() { + void emptyName() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -149,7 +149,7 @@ public void emptyName() { } @Test - public void dotInName() { + void dotInName() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -212,7 +212,7 @@ public void dotInName() { } @Test - public void nameCollision_fieldTemplates() { + void nameCollision_fieldTemplates() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -245,7 +245,7 @@ public void nameCollision_fieldTemplates() { } @Test - public void nameCollision_objectFieldTemplates() { + void nameCollision_objectFieldTemplates() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -278,7 +278,7 @@ public void nameCollision_objectFieldTemplates() { } @Test - public void nameCollision_fieldTemplateAndObjectFieldTemplate() { + void nameCollision_fieldTemplateAndObjectFieldTemplate() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementTypeIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementTypeIT.java index e53bb30a09b..43236847740 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementTypeIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/document/IndexSchemaElementTypeIT.java @@ -15,13 +15,13 @@ import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.engine.mapper.mapping.building.spi.IndexBindingContext; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test the behavior of implementations of {@link IndexSchemaElement} when defining field types. @@ -30,15 +30,15 @@ * since this would require backend-specific code to inspect that schema. * However, in search and projection tests, we check that defined fields behave correctly at runtime. */ -public class IndexSchemaElementTypeIT { +class IndexSchemaElementTypeIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private StubMappedIndex index; @Test - public void analyzerOnSortableField() { + void analyzerOnSortableField() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -70,7 +70,7 @@ public void analyzerOnSortableField() { } @Test - public void analyzerOnAggregableField() { + void analyzerOnAggregableField() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -103,7 +103,7 @@ public void analyzerOnAggregableField() { } @Test - public void analyzerAndNormalizer() { + void analyzerAndNormalizer() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); @@ -130,7 +130,7 @@ public void analyzerAndNormalizer() { } @Test - public void searchAnalyzerWithoutAnalyzer() { + void searchAnalyzerWithoutAnalyzer() { assertThatThrownBy( () -> setup( ctx -> { IndexSchemaElement root = ctx.schemaElement(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/dynamic/FieldTemplateIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/dynamic/FieldTemplateIT.java index 1e1a3449056..620a990181c 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/dynamic/FieldTemplateIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/dynamic/FieldTemplateIT.java @@ -31,17 +31,17 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.IndexFieldLocation; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests for fields defined through field templates. @@ -56,16 +56,14 @@ * We do not test all features (sorts, aggregations, ...) because we expect the backend * to rely on the same generic code for all features. */ -@RunWith(Parameterized.class) -public class FieldTemplateIT { +class FieldTemplateIT { - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - List parameters = new ArrayList<>(); + public static List params() { + List parameters = new ArrayList<>(); for ( TestedFieldStructure fieldStructure : TestedFieldStructure.all() ) { - parameters.add( new Object[] { fieldStructure } ); + parameters.add( Arguments.of( fieldStructure ) ); } - return parameters.toArray( new Object[0][] ); + return parameters; } private static final String DOCUMENT_1 = "1"; @@ -73,20 +71,16 @@ public static Object[][] parameters() { private static final String EMPTY = "empty"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); - - private final TestedFieldStructure fieldStructure; + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private SimpleMappedIndex index; - public FieldTemplateIT(TestedFieldStructure fieldStructure) { - this.fieldStructure = fieldStructure; - } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3273") - public void simple() { + void simple(TestedFieldStructure fieldStructure) { Consumer templatesBinder = root -> { IndexSchemaFieldTemplateOptionsStep step = root.fieldTemplate( "myTemplate", f -> f.asString() ); @@ -95,36 +89,39 @@ public void simple() { } }; StubMapping mapping = - setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY, templatesBinder ); + setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY, templatesBinder, + fieldStructure + ); // Index a few documents index.bulkIndexer() .add( EMPTY, document -> {} ) - .add( DOCUMENT_1, document -> initDocument( document, "foo", + .add( DOCUMENT_1, document -> initDocument( document, fieldStructure, "foo", "matchedValue", "notMatchedValue1", "notMatchedValue2" ) ) - .add( DOCUMENT_2, document -> initDocument( document, "foo", + .add( DOCUMENT_2, document -> initDocument( document, fieldStructure, "foo", "notMatchedValue1", "notMatchedValue1", "matchedValue" ) ) .join(); // Check that documents are indexed and the dynamic field can be searched assertThatQuery( query( - f -> f.match().field( getFieldPath( "foo" ) ).matching( "matchedValue" ) ) + f -> f.match().field( getFieldPath( "foo", fieldStructure ) ).matching( "matchedValue" ), fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); // Try again with a clean Hibernate Search instance, where local schema caches are empty mapping.close(); - setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, templatesBinder ); + setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, templatesBinder, fieldStructure ); assertThatQuery( query( - f -> f.match().field( getFieldPath( "foo" ) ).matching( "matchedValue" ) ) + f -> f.match().field( getFieldPath( "foo", fieldStructure ) ).matching( "matchedValue" ), fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3273") - public void matchingPathGlob() { + void matchingPathGlob(TestedFieldStructure fieldStructure) { Consumer templatesBinder = root -> { IndexSchemaFieldTemplateOptionsStep step = root.fieldTemplate( "stringTemplate", f -> f.asString() ) .matchingPathGlob( "*_str" ); @@ -139,44 +136,47 @@ public void matchingPathGlob() { }; StubMapping mapping = - setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY, templatesBinder ); + setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY, templatesBinder, + fieldStructure + ); // Index a few documents index.bulkIndexer() .add( EMPTY, document -> {} ) - .add( DOCUMENT_1, document -> initDocument( document, "foo_str", + .add( DOCUMENT_1, document -> initDocument( document, fieldStructure, "foo_str", "matchedValue", "notMatchedValue1", "notMatchedValue2" ) ) - .add( DOCUMENT_2, document -> initDocument( document, "foo_int", + .add( DOCUMENT_2, document -> initDocument( document, fieldStructure, "foo_int", 42, 52, 56 ) ) .join(); // Check that documents are indexed and the dynamic fields can be searched assertThatQuery( query( - f -> f.match().field( getFieldPath( "foo_str" ) ).matching( "matchedValue" ) ) + f -> f.match().field( getFieldPath( "foo_str", fieldStructure ) ).matching( "matchedValue" ), fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); assertThatQuery( query( - f -> f.match().field( getFieldPath( "foo_int" ) ).matching( 42 ) ) + f -> f.match().field( getFieldPath( "foo_int", fieldStructure ) ).matching( 42 ), fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_2 ); // Try again with a clean Hibernate Search instance, where local schema caches are empty mapping.close(); - setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, templatesBinder ); + setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, templatesBinder, fieldStructure ); assertThatQuery( query( - f -> f.match().field( getFieldPath( "foo_str" ) ).matching( "matchedValue" ) ) + f -> f.match().field( getFieldPath( "foo_str", fieldStructure ) ).matching( "matchedValue" ), fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); assertThatQuery( query( - f -> f.match().field( getFieldPath( "foo_int" ) ).matching( 42 ) ) + f -> f.match().field( getFieldPath( "foo_int", fieldStructure ) ).matching( 42 ), fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_2 ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3273") - public void matchingPathGlob_precedence_firstDeclared() { + void matchingPathGlob_precedence_firstDeclared(TestedFieldStructure fieldStructure) { Consumer templatesBinder = root -> { IndexSchemaFieldTemplateOptionsStep step = root.fieldTemplate( "stringTemplate", f -> f.asString() ) .matchingPathGlob( "*_str_int" ); @@ -196,48 +196,55 @@ public void matchingPathGlob_precedence_firstDeclared() { }; StubMapping mapping = - setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY, templatesBinder ); + setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY, templatesBinder, + fieldStructure + ); // Index a few documents index.bulkIndexer() .add( EMPTY, document -> {} ) - .add( DOCUMENT_1, document -> initDocument( document, "foo_str_int", + .add( DOCUMENT_1, document -> initDocument( document, fieldStructure, "foo_str_int", "42", "notMatchedValue1", "notMatchedValue2" ) ) - .add( DOCUMENT_2, document -> initDocument( document, "foo_int", + .add( DOCUMENT_2, document -> initDocument( document, fieldStructure, "foo_int", 42, 52, 56 ) ) .join(); // Check that dynamic fields have the correct type assertThatQuery( query( - f -> f.range().field( getFieldPath( "foo_str_int" ) ) - .between( "3000", "5000" ) ) + f -> f.range().field( getFieldPath( "foo_str_int", fieldStructure ) ) + .between( "3000", "5000" ), + fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); assertThatQuery( query( - f -> f.range().field( getFieldPath( "foo_int" ) ) - .between( 41, 43 ) ) + f -> f.range().field( getFieldPath( "foo_int", fieldStructure ) ) + .between( 41, 43 ), + fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_2 ); // Try again with a clean Hibernate Search instance, where local schema caches are empty mapping.close(); - setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, templatesBinder ); + setup( StubMappingSchemaManagementStrategy.DROP_ON_SHUTDOWN_ONLY, templatesBinder, fieldStructure ); assertThatQuery( query( - f -> f.range().field( getFieldPath( "foo_str_int" ) ) - .between( "3000", "5000" ) ) + f -> f.range().field( getFieldPath( "foo_str_int", fieldStructure ) ) + .between( "3000", "5000" ), + fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); assertThatQuery( query( - f -> f.range().field( getFieldPath( "foo_int" ) ) - .between( 41, 43 ) ) + f -> f.range().field( getFieldPath( "foo_int", fieldStructure ) ) + .between( 41, 43 ), + fieldStructure ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_2 ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4500") - public void parentTemplate_wrongType() { + void parentTemplate_wrongType(TestedFieldStructure fieldStructure) { Consumer templatesBinder = root -> { root.fieldTemplate( "template1", f -> f.asString() ); IndexSchemaFieldTemplateOptionsStep step = @@ -247,29 +254,30 @@ public void parentTemplate_wrongType() { step.multiValued(); } }; - setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY, templatesBinder ); + setup( StubMappingSchemaManagementStrategy.DROP_AND_CREATE_ON_STARTUP_ONLY, templatesBinder, fieldStructure ); assertThatThrownBy( () -> index.createIndexer().add( referenceProvider( DOCUMENT_1 ), - document -> initDocument( document, "parent.foo", + document -> initDocument( document, fieldStructure, "parent.foo", "matchedValue", "notMatchedValue1", "notMatchedValue2" ), DocumentCommitStrategy.FORCE, DocumentRefreshStrategy.NONE, OperationSubmitter.blocking() ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( - "Unable to resolve field '" + getFieldPath( "parent.foo" ) + "'", - "Invalid type: field '" + getFieldPath( "parent" ) + "' is not composite" + "Unable to resolve field '" + getFieldPath( "parent.foo", fieldStructure ) + "'", + "Invalid type: field '" + getFieldPath( "parent", fieldStructure ) + "' is not composite" ); } private SearchQuery query( - Function predicateContributor) { + Function predicateContributor, + TestedFieldStructure fieldStructure) { return index.createScope().query() .where( f -> { if ( fieldStructure.isInNested() ) { - return f.nested( getParentFieldPath() ) + return f.nested( getParentFieldPath( fieldStructure ) ) .add( predicateContributor ) - .add( f.match().field( getFieldPath( "discriminator" ) ) + .add( f.match().field( getFieldPath( "discriminator", fieldStructure ) ) .matching( "included" ) ); } else { @@ -279,8 +287,8 @@ private SearchQuery query( .toQuery(); } - private String getFieldPath(String relativeFieldName) { - String parentFieldPath = getParentFieldPath(); + private String getFieldPath(String relativeFieldName, TestedFieldStructure fieldStructure) { + String parentFieldPath = getParentFieldPath( fieldStructure ); if ( parentFieldPath.isEmpty() ) { return relativeFieldName; } @@ -289,7 +297,7 @@ private String getFieldPath(String relativeFieldName) { } } - private String getParentFieldPath() { + private String getParentFieldPath(TestedFieldStructure fieldStructure) { IndexBinding binding = index.binding(); switch ( fieldStructure.location ) { case ROOT: @@ -307,15 +315,15 @@ private String getParentFieldPath() { } private StubMapping setup(StubMappingSchemaManagementStrategy schemaManagementStrategy, - Consumer templatesBinder) { - this.index = SimpleMappedIndex.of( root -> new IndexBinding( root, templatesBinder ) ); + Consumer templatesBinder, TestedFieldStructure fieldStructure) { + this.index = SimpleMappedIndex.of( root -> new IndexBinding( root, templatesBinder, fieldStructure ) ); return setupHelper.start().withIndex( index ) .withSchemaManagement( schemaManagementStrategy ) .setup(); } - private void initDocument(DocumentElement document, String fieldName, + private void initDocument(DocumentElement document, TestedFieldStructure fieldStructure, String fieldName, T value1, T value2, T excludedValue) { IndexBinding binding = index.binding(); switch ( fieldStructure.location ) { @@ -366,13 +374,14 @@ private class IndexBinding { final FlattenedObjectBinding flattenedObject; final NestedObjectBinding nestedObject; - IndexBinding(IndexSchemaElement root, Consumer templatesBinder) { + IndexBinding(IndexSchemaElement root, Consumer templatesBinder, + TestedFieldStructure fieldStructure) { if ( fieldStructure.location.equals( IndexFieldLocation.ROOT ) ) { templatesBinder.accept( root ); } - flattenedObject = new FlattenedObjectBinding( root, "flattenedObject", templatesBinder ); - nestedObject = new NestedObjectBinding( root, "nestedObject", templatesBinder ); + flattenedObject = new FlattenedObjectBinding( root, "flattenedObject", templatesBinder, fieldStructure ); + nestedObject = new NestedObjectBinding( root, "nestedObject", templatesBinder, fieldStructure ); } } @@ -381,7 +390,7 @@ private class FlattenedObjectBinding { final IndexObjectFieldReference self; private FlattenedObjectBinding(IndexSchemaElement parent, String relativeFieldName, - Consumer templatesBinder) { + Consumer templatesBinder, TestedFieldStructure fieldStructure) { this.relativeFieldName = relativeFieldName; IndexSchemaObjectField objectField = parent.objectField( relativeFieldName, ObjectStructure.FLATTENED ); @@ -402,7 +411,7 @@ private class NestedObjectBinding { final SecondLevelNestedObjectBinding nestedObject; private NestedObjectBinding(IndexSchemaElement parent, String relativeFieldName, - Consumer templatesBinder) { + Consumer templatesBinder, TestedFieldStructure fieldStructure) { this.relativeFieldName = relativeFieldName; IndexSchemaObjectField objectField = parent.objectField( relativeFieldName, ObjectStructure.NESTED ); @@ -416,7 +425,8 @@ private NestedObjectBinding(IndexSchemaElement parent, String relativeFieldName, discriminator = objectField.field( "discriminator", f -> f.asString() ).toReference(); nestedObject = new SecondLevelNestedObjectBinding( objectField, "nestedObject", - templatesBinder ); + templatesBinder, fieldStructure + ); } } @@ -427,7 +437,7 @@ private class SecondLevelNestedObjectBinding { final IndexFieldReference discriminator; private SecondLevelNestedObjectBinding(IndexSchemaElement parent, String relativeFieldName, - Consumer templatesBinder) { + Consumer templatesBinder, TestedFieldStructure fieldStructure) { this.relativeFieldName = relativeFieldName; IndexSchemaObjectField objectField = parent.objectField( relativeFieldName, ObjectStructure.NESTED ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/dynamic/ObjectFieldTemplateIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/dynamic/ObjectFieldTemplateIT.java index bc9928e27ec..83021b2b99a 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/dynamic/ObjectFieldTemplateIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/dynamic/ObjectFieldTemplateIT.java @@ -21,19 +21,19 @@ import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests for object fields defined through field templates. */ -public class ObjectFieldTemplateIT { +class ObjectFieldTemplateIT { private static final String DOCUMENT_MATCHING_FOR_NESTED = "matchingNested"; private static final String DOCUMENT_MATCHING_FOR_ALL = "matchingForAll"; @@ -49,14 +49,14 @@ public class ObjectFieldTemplateIT { private static final String FIRSTNAME_2 = "ty"; private static final String LASTNAME_2 = "frank"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private SimpleMappedIndex index; @Test @TestForIssue(jiraKey = "HSEARCH-3273") - public void simple() { + void simple() { Consumer templatesBinder = root -> { root.fieldTemplate( "fieldTemplate", f -> f.asString() ) .matchingPathGlob( VALUE_FIELD_PATH_GLOB ); @@ -104,7 +104,7 @@ public void simple() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3273") - public void inherited() { + void inherited() { Consumer templatesBinder = root -> { root.fieldTemplate( "fieldTemplate", f -> f.asString() ) .matchingPathGlob( VALUE_FIELD_PATH_GLOB ); @@ -153,7 +153,7 @@ public void inherited() { @Test @TestForIssue(jiraKey = "HSEARCH-3273") - public void matchingPathGlob() { + void matchingPathGlob() { Consumer templatesBinder = root -> { root.fieldTemplate( "fieldTemplate", f -> f.asString() ) .matchingPathGlob( VALUE_FIELD_PATH_GLOB ); @@ -218,7 +218,7 @@ public void matchingPathGlob() { @Test @TestForIssue(jiraKey = { "HSEARCH-3273", "HSEARCH-4048" }) - public void matchingPathGlob_precedence_firstDeclared() { + void matchingPathGlob_precedence_firstDeclared() { Consumer templatesBinder = root -> { root.fieldTemplate( "fieldTemplate", f -> f.asString() ) .matchingPathGlob( VALUE_FIELD_PATH_GLOB ); @@ -287,7 +287,7 @@ public void matchingPathGlob_precedence_firstDeclared() { @Test @TestForIssue(jiraKey = "HSEARCH-3273") - public void matchingPathGlob_precedence_deepestDeclared() { + void matchingPathGlob_precedence_deepestDeclared() { Consumer rootTemplatesBinder = root -> { root.fieldTemplate( "fieldTemplate", f -> f.asString() ) .matchingPathGlob( VALUE_FIELD_PATH_GLOB ); @@ -362,7 +362,7 @@ public void matchingPathGlob_precedence_deepestDeclared() { */ @Test @TestForIssue(jiraKey = { "HSEARCH-3273", "HSEARCH-3905" }) - public void exists_staticObjectField() { + void exists_staticObjectField() { Consumer rootTemplatesBinder = root -> {}; Consumer staticObjectTemplatesBinder = staticObject -> { staticObject.fieldTemplate( "fieldTemplate", f -> f.asString() ) @@ -425,7 +425,7 @@ public void exists_staticObjectField() { */ @Test @TestForIssue(jiraKey = { "HSEARCH-3273", "HSEARCH-3905" }) - public void exists_dynamicObjectField() { + void exists_dynamicObjectField() { Consumer templatesBinder = root -> { root.fieldTemplate( "fieldTemplate", f -> f.asString() ) .matchingPathGlob( VALUE_FIELD_PATH_GLOB ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/index/IndexManagerIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/index/IndexManagerIT.java index 2c9a8d7eac0..d96e6f7fded 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/index/IndexManagerIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/index/IndexManagerIT.java @@ -10,28 +10,28 @@ import org.hibernate.search.engine.backend.Backend; import org.hibernate.search.engine.backend.index.IndexManager; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexManagerIT { +class IndexManagerIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final StubMappedIndex index = StubMappedIndex.withoutFields(); private static Backend backendApi; private static IndexManager indexApi; - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { StubMapping mapping = setupHelper.start().withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.NONE ) .setup(); @@ -41,7 +41,7 @@ public static void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void backend() { + void backend() { assertThat( indexApi.backend() ) .isNotNull() .isSameAs( backendApi ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/indexnull/IndexNullAsValueIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/indexnull/IndexNullAsValueIT.java index f6b0dce2d84..f055a4496fa 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/indexnull/IndexNullAsValueIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/indexnull/IndexNullAsValueIT.java @@ -22,28 +22,28 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.expectations.IndexNullAsMatchPredicateExpectactions; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.StandardFieldMapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexNullAsValueIT { +class IndexNullAsValueIT { private static final String DOCUMENT_WITH_INDEX_NULL_AS_VALUES = "documentWithIndexNullAsValues"; private static final String DOCUMENT_WITH_DIFFERENT_VALUES = "documentWithDifferentValues"; private static final String DOCUMENT_WITH_NULL_VALUES = "documentWithNullValues"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); @Test - public void indexNullAsValue_match() { + void indexNullAsValue_match() { setUp(); StubMappingScope scope = index.createScope(); @@ -61,7 +61,7 @@ public void indexNullAsValue_match() { } @Test - public void indexNullAsValue_spatial() { + void indexNullAsValue_spatial() { setUp(); SearchQuery query = index.createScope().query() .where( f -> f.spatial().within().field( "geoPointField" ).circle( GeoPoint.of( 0.0, 0.0 ), 1 ) ) @@ -72,7 +72,7 @@ public void indexNullAsValue_spatial() { } @Test - public void indexNullAsValue_fullText() { + void indexNullAsValue_fullText() { assertThatThrownBy( () -> setupHelper.start() .withIndex( StubMappedIndex.ofNonRetrievable( root -> root.field( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexDescriptorIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexDescriptorIT.java index 0f7783a99b7..a0812e571bb 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexDescriptorIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexDescriptorIT.java @@ -15,42 +15,42 @@ import org.hibernate.search.engine.backend.metamodel.IndexCompositeElementDescriptor; import org.hibernate.search.engine.backend.metamodel.IndexDescriptor; import org.hibernate.search.engine.backend.metamodel.IndexFieldDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests for basic index descriptor features that are not tested elsewhere. */ @TestForIssue(jiraKey = "HSEARCH-3589") -public class IndexDescriptorIT { +class IndexDescriptorIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.NONE ) .setup(); } @Test - public void name() { + void name() { IndexDescriptor indexDescriptor = index.toApi().descriptor(); assertThat( indexDescriptor.hibernateSearchName() ).isEqualTo( index.name() ); } @Test - public void root() { + void root() { IndexDescriptor indexDescriptor = index.toApi().descriptor(); assertThat( indexDescriptor.root() ).isNotNull() @@ -59,7 +59,7 @@ public void root() { } @Test - public void staticFields() { + void staticFields() { IndexDescriptor indexDescriptor = index.toApi().descriptor(); Optional valueFieldDescriptorOptional = indexDescriptor.field( "myValueField" ); @@ -76,7 +76,7 @@ public void staticFields() { } @Test - public void dynamicFields() { + void dynamicFields() { IndexDescriptor indexDescriptor = index.toApi().descriptor(); Optional valueFieldDescriptorOptional = indexDescriptor.field( "myDynamicField_txt" ); @@ -92,7 +92,7 @@ public void dynamicFields() { } @Test - public void missingField() { + void missingField() { IndexDescriptor indexDescriptor = index.toApi().descriptor(); Optional fieldDescriptorOptional = indexDescriptor.field( "unknownField" ); assertThat( fieldDescriptorOptional ).isEmpty(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexFieldDescriptorIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexFieldDescriptorIT.java index ae8bfea023c..0e4072bb3b4 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexFieldDescriptorIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexFieldDescriptorIT.java @@ -28,17 +28,17 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.IndexFieldLocation; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.assertj.core.api.Assertions; @@ -48,41 +48,34 @@ * Tests for type-related features are located in {@link IndexValueFieldTypeDescriptorBaseIT} * and {@link IndexObjectFieldTypeDescriptorBaseIT}. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3589") -public class IndexFieldDescriptorIT { +class IndexFieldDescriptorIT { - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - List parameters = new ArrayList<>(); + public static List params() { + List parameters = new ArrayList<>(); for ( TestedFieldStructure fieldStructure : TestedFieldStructure.all() ) { - parameters.add( new Object[] { fieldStructure } ); + parameters.add( Arguments.of( fieldStructure ) ); } - return parameters.toArray( new Object[0][] ); + return parameters; } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.NONE ) .setup(); } - private final TestedFieldStructure fieldStructure; - - public IndexFieldDescriptorIT(TestedFieldStructure fieldStructure) { - this.fieldStructure = fieldStructure; - } - - @Test - public void valueField() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void valueField(TestedFieldStructure fieldStructure) { IndexDescriptor indexDescriptor = index.toApi().descriptor(); - IndexFieldDescriptor baseFieldDescriptor = indexDescriptor.field( getAbsoluteFieldPath() ).get(); + IndexFieldDescriptor baseFieldDescriptor = indexDescriptor.field( getAbsoluteFieldPath( fieldStructure ) ).get(); // Basic getters assertThat( baseFieldDescriptor ) @@ -94,12 +87,12 @@ public void valueField() { assertThatThrownBy( fieldDescriptor::toObjectField ) .isInstanceOf( SearchException.class ) .hasMessageContaining( - "Invalid type: field '" + getAbsoluteFieldPath() + "' is not an object field" + "Invalid type: field '" + getAbsoluteFieldPath( fieldStructure ) + "' is not an object field" ); assertThat( fieldDescriptor ) - .returns( getRelativeFieldName(), IndexFieldDescriptor::relativeName ) - .returns( getAbsoluteFieldPath(), IndexFieldDescriptor::absolutePath ) + .returns( getRelativeFieldName( fieldStructure ), IndexFieldDescriptor::relativeName ) + .returns( getAbsoluteFieldPath( fieldStructure ), IndexFieldDescriptor::absolutePath ) .returns( fieldStructure.isMultiValued(), IndexFieldDescriptor::multiValued ) // In this specific test, we decided that nested fields are multi-valued, while flattened fields are not. // That's just a detail though: the two characteristics are not usually related. @@ -112,10 +105,11 @@ public void valueField() { assertThat( type ).isNotNull(); } - @Test - public void parent() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void parent(TestedFieldStructure fieldStructure) { IndexDescriptor indexDescriptor = index.toApi().descriptor(); - IndexFieldDescriptor childFieldDescriptor = indexDescriptor.field( getAbsoluteFieldPath() ).get(); + IndexFieldDescriptor childFieldDescriptor = indexDescriptor.field( getAbsoluteFieldPath( fieldStructure ) ).get(); IndexCompositeElementDescriptor elementDescriptor = childFieldDescriptor.parent(); assertThat( elementDescriptor ).isNotNull(); @@ -151,7 +145,7 @@ public void parent() { assertThatThrownBy( fieldDescriptor::toValueField ) .isInstanceOf( SearchException.class ) .hasMessageContaining( - "Invalid type: field '" + getParentAbsoluteFieldPath() + "' is not a value field" + "Invalid type: field '" + getParentAbsoluteFieldPath( fieldStructure ) + "' is not a value field" ); // Basic getters @@ -159,8 +153,8 @@ public void parent() { .returns( true, IndexFieldDescriptor::isObjectField ) .returns( false, IndexFieldDescriptor::isValueField ); assertThat( fieldDescriptor ) - .returns( getParentRelativeFieldName(), IndexFieldDescriptor::relativeName ) - .returns( getParentAbsoluteFieldPath(), IndexFieldDescriptor::absolutePath ) + .returns( getParentRelativeFieldName( fieldStructure ), IndexFieldDescriptor::relativeName ) + .returns( getParentAbsoluteFieldPath( fieldStructure ), IndexFieldDescriptor::absolutePath ) // In this specific test, we decided that nested fields are multi-valued, while flattened fields are not. // That's just a detail though: the two characteristics are not usually related. .returns( fieldStructure.isInNested(), IndexFieldDescriptor::multiValued ) @@ -178,7 +172,7 @@ public void parent() { @SuppressWarnings("unchecked") // Workaround for assertThat(Map) not taking wildcard type into account like assertThat(Collection) does Map castChildrenByName = (Map) childrenByName; assertThat( castChildrenByName ) - .contains( entry( getRelativeFieldName(), childFieldDescriptor ) ); + .contains( entry( getRelativeFieldName( fieldStructure ), childFieldDescriptor ) ); switch ( fieldStructure.location ) { case IN_FLATTENED: @@ -246,7 +240,7 @@ public void parent() { } } - private String getRelativeFieldName() { + private String getRelativeFieldName(TestedFieldStructure fieldStructure) { if ( fieldStructure.isSingleValued() ) { return "myField"; } @@ -255,17 +249,17 @@ private String getRelativeFieldName() { } } - private String getAbsoluteFieldPath() { - String parentFieldPath = getParentAbsoluteFieldPath(); + private String getAbsoluteFieldPath(TestedFieldStructure fieldStructure) { + String parentFieldPath = getParentAbsoluteFieldPath( fieldStructure ); if ( parentFieldPath.isEmpty() ) { - return getRelativeFieldName(); + return getRelativeFieldName( fieldStructure ); } else { - return parentFieldPath + "." + getRelativeFieldName(); + return parentFieldPath + "." + getRelativeFieldName( fieldStructure ); } } - private String getParentAbsoluteFieldPath() { + private String getParentAbsoluteFieldPath(TestedFieldStructure fieldStructure) { IndexBinding binding = index.binding(); switch ( fieldStructure.location ) { case ROOT: @@ -282,7 +276,7 @@ private String getParentAbsoluteFieldPath() { } } - private String getParentRelativeFieldName() { + private String getParentRelativeFieldName(TestedFieldStructure fieldStructure) { IndexBinding binding = index.binding(); switch ( fieldStructure.location ) { case ROOT: diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexObjectFieldTypeDescriptorBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexObjectFieldTypeDescriptorBaseIT.java index b433193260d..9ed6b4f7b82 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexObjectFieldTypeDescriptorBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexObjectFieldTypeDescriptorBaseIT.java @@ -13,35 +13,35 @@ import org.hibernate.search.engine.backend.metamodel.IndexObjectFieldDescriptor; import org.hibernate.search.engine.backend.metamodel.IndexObjectFieldTypeDescriptor; import org.hibernate.search.engine.backend.types.ObjectStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Basic tests for object field type descriptor features. */ @TestForIssue(jiraKey = "HSEARCH-3589") -public class IndexObjectFieldTypeDescriptorBaseIT { +class IndexObjectFieldTypeDescriptorBaseIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.NONE ) .setup(); } @Test - public void isNested() { + void isNested() { assertThat( getTypeDescriptor( "default" ) ) .returns( false, IndexObjectFieldTypeDescriptor::nested ); assertThat( getTypeDescriptor( "flattened" ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexValueFieldTypeDescriptorBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexValueFieldTypeDescriptorBaseIT.java index c0d25668db2..031ab23615b 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexValueFieldTypeDescriptorBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexValueFieldTypeDescriptorBaseIT.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.metamodel.IndexDescriptor; @@ -28,49 +29,45 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.NormalizedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Basic tests for value field type descriptor features, for every relevant field type. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3589") -public class IndexValueFieldTypeDescriptorBaseIT { +class IndexValueFieldTypeDescriptorBaseIT { - @Parameterized.Parameters(name = "{0}") - public static List> parameters() { - return FieldTypeDescriptor.getAll(); + public static List params() { + return FieldTypeDescriptor.getAll().stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); + private SimpleMappedIndex index; - private final FieldTypeDescriptor fieldType; - - public IndexValueFieldTypeDescriptorBaseIT(FieldTypeDescriptor fieldType) { - this.fieldType = fieldType; - } - - @Before - public void setup() { + public void init(FieldTypeDescriptor fieldType) { + index = SimpleMappedIndex.of( + root -> new IndexBinding( root, fieldType ) ); setupHelper.start().withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.NONE ) .setup(); } - @Test - public void isSearchable() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void isSearchable(FieldTypeDescriptor fieldType) { + init( fieldType ); assertThat( getTypeDescriptor( "default" ) ) .returns( true, IndexValueFieldTypeDescriptor::searchable ); assertThat( getTypeDescriptor( "searchable" ) ) @@ -79,14 +76,16 @@ public void isSearchable() { .returns( false, IndexValueFieldTypeDescriptor::searchable ); } - @Test - public void isSortable() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void isSortable(FieldTypeDescriptor fieldType) { + init( fieldType ); boolean projectable = TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault(); assertThat( getTypeDescriptor( "default" ) ) .returns( GeoPointFieldTypeDescriptor.INSTANCE.equals( fieldType ) ? projectable : false, IndexValueFieldTypeDescriptor::sortable ); - if ( isSortSupported() ) { + if ( isSortSupported( fieldType ) ) { assertThat( getTypeDescriptor( "sortable" ) ) .returns( true, IndexValueFieldTypeDescriptor::sortable ); } @@ -95,8 +94,10 @@ public void isSortable() { IndexValueFieldTypeDescriptor::sortable ); } - @Test - public void isProjectable() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void isProjectable(FieldTypeDescriptor fieldType) { + init( fieldType ); boolean projectable = TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault(); assertThat( getTypeDescriptor( "default" ) ) .returns( projectable, IndexValueFieldTypeDescriptor::projectable ); @@ -106,11 +107,13 @@ public void isProjectable() { .returns( false, IndexValueFieldTypeDescriptor::projectable ); } - @Test - public void isAggregable() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void isAggregable(FieldTypeDescriptor fieldType) { + init( fieldType ); assertThat( getTypeDescriptor( "default" ) ) .returns( false, IndexValueFieldTypeDescriptor::aggregable ); - if ( isAggregationSupported() ) { + if ( isAggregationSupported( fieldType ) ) { assertThat( getTypeDescriptor( "aggregable" ) ) .returns( true, IndexValueFieldTypeDescriptor::aggregable ); } @@ -118,8 +121,10 @@ public void isAggregable() { .returns( false, IndexValueFieldTypeDescriptor::aggregable ); } - @Test - public void dslArgumentClass() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dslArgumentClass(FieldTypeDescriptor fieldType) { + init( fieldType ); assertThat( getTypeDescriptor( "default" ) ) .returns( fieldType.getJavaType(), IndexValueFieldTypeDescriptor::dslArgumentClass ); assertThat( getTypeDescriptor( "dslConverter" ) ) @@ -128,8 +133,10 @@ public void dslArgumentClass() { .returns( fieldType.getJavaType(), IndexValueFieldTypeDescriptor::dslArgumentClass ); } - @Test - public void projectedValueClass() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectedValueClass(FieldTypeDescriptor fieldType) { + init( fieldType ); assertThat( getTypeDescriptor( "default" ) ) .returns( fieldType.getJavaType(), IndexValueFieldTypeDescriptor::projectedValueClass ); assertThat( getTypeDescriptor( "dslConverter" ) ) @@ -138,8 +145,10 @@ public void projectedValueClass() { .returns( ValueWrapper.class, IndexValueFieldTypeDescriptor::projectedValueClass ); } - @Test - public void valueClass() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void valueClass(FieldTypeDescriptor fieldType) { + init( fieldType ); assertThat( getTypeDescriptor( "default" ) ) .returns( fieldType.getJavaType(), IndexValueFieldTypeDescriptor::valueClass ); assertThat( getTypeDescriptor( "dslConverter" ) ) @@ -148,8 +157,10 @@ public void valueClass() { .returns( fieldType.getJavaType(), IndexValueFieldTypeDescriptor::valueClass ); } - @Test - public void searchAnalyzerName() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void searchAnalyzerName(FieldTypeDescriptor fieldType) { + init( fieldType ); IndexValueFieldTypeDescriptor typeDescriptor = getTypeDescriptor( "default" ); Optional searchAnalyzerName = typeDescriptor.searchAnalyzerName(); @@ -162,8 +173,10 @@ public void searchAnalyzerName() { } } - @Test - public void normalizerName() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void normalizerName(FieldTypeDescriptor fieldType) { + init( fieldType ); IndexValueFieldTypeDescriptor typeDescriptor = getTypeDescriptor( "default" ); Optional normalizerName = typeDescriptor.normalizerName(); @@ -182,16 +195,16 @@ private IndexValueFieldTypeDescriptor getTypeDescriptor(String fieldName) { return fieldDescriptor.type(); } - private boolean isSortSupported() { + private boolean isSortSupported(FieldTypeDescriptor fieldType) { return fieldType.isFieldSortSupported(); } - private boolean isAggregationSupported() { + private boolean isAggregationSupported(FieldTypeDescriptor fieldType) { return TermsAggregationDescriptor.INSTANCE.getSingleFieldAggregationExpectations( fieldType ).isSupported(); } private class IndexBinding { - IndexBinding(IndexSchemaElement root) { + IndexBinding(IndexSchemaElement root, FieldTypeDescriptor fieldType) { mapper( fieldType, ignored -> {} ).map( root, "default" ); mapper( fieldType, c -> c.dslConverter( ValueWrapper.class, ValueWrapper.toDocumentValueConverter() ) ) @@ -201,13 +214,13 @@ private class IndexBinding { mapper( fieldType, c -> c.searchable( Searchable.YES ) ).map( root, "searchable" ); mapper( fieldType, c -> c.searchable( Searchable.NO ) ).map( root, "nonSearchable" ); - if ( isSortSupported() ) { + if ( isSortSupported( fieldType ) ) { mapper( fieldType, c -> c.sortable( Sortable.YES ) ).map( root, "sortable" ); } mapper( fieldType, c -> c.sortable( Sortable.NO ) ).map( root, "nonSortable" ); mapper( fieldType, c -> c.projectable( Projectable.YES ) ).map( root, "projectable" ); mapper( fieldType, c -> c.projectable( Projectable.NO ) ).map( root, "nonProjectable" ); - if ( isAggregationSupported() ) { + if ( isAggregationSupported( fieldType ) ) { mapper( fieldType, c -> c.aggregable( Aggregable.YES ) ).map( root, "aggregable" ); } mapper( fieldType, c -> c.aggregable( Aggregable.NO ) ).map( root, "nonAggregable" ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexValueFieldTypeDescriptorStringSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexValueFieldTypeDescriptorStringSpecificsIT.java index 62736a9a978..14a8aac53ce 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexValueFieldTypeDescriptorStringSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/metamodel/IndexValueFieldTypeDescriptorStringSpecificsIT.java @@ -13,36 +13,36 @@ import org.hibernate.search.engine.backend.metamodel.IndexValueFieldDescriptor; import org.hibernate.search.engine.backend.metamodel.IndexValueFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests for value field type descriptor features that are specific to String field types * and are not already tested in {@link IndexValueFieldTypeDescriptorBaseIT}. */ @TestForIssue(jiraKey = "HSEARCH-3589") -public class IndexValueFieldTypeDescriptorStringSpecificsIT { +class IndexValueFieldTypeDescriptorStringSpecificsIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ) .withSchemaManagement( StubMappingSchemaManagementStrategy.NONE ) .setup(); } @Test - public void analyzerName() { + void analyzerName() { assertThat( getTypeDescriptor( "noSearchAnalyzer" ).analyzerName() ) .contains( DefaultAnalysisDefinitions.ANALYZER_NGRAM.name ); assertThat( getTypeDescriptor( "searchAnalyzer" ).analyzerName() ) @@ -50,7 +50,7 @@ public void analyzerName() { } @Test - public void searchAnalyzerName() { + void searchAnalyzerName() { assertThat( getTypeDescriptor( "noSearchAnalyzer" ).searchAnalyzerName() ) .contains( DefaultAnalysisDefinitions.ANALYZER_NGRAM.name ); assertThat( getTypeDescriptor( "searchAnalyzer" ).searchAnalyzerName() ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/multitenancy/MultiTenancyBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/multitenancy/MultiTenancyBaseIT.java index d9eec3e579b..9de397db321 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/multitenancy/MultiTenancyBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/multitenancy/MultiTenancyBaseIT.java @@ -24,7 +24,7 @@ import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; @@ -32,11 +32,11 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubSession; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MultiTenancyBaseIT { +class MultiTenancyBaseIT { private static final String TENANT_1 = "tenant_1"; private static final String TENANT_2 = "tenant_2"; @@ -56,17 +56,17 @@ public class MultiTenancyBaseIT { private static final Integer INTEGER_VALUE_4 = 4; private static final Integer INTEGER_VALUE_5 = 5; - @Rule + @RegisterExtension public final SearchSetupHelper setupHelper = - new SearchSetupHelper( TckBackendHelper::createMultiTenancyBackendSetupStrategy ); + SearchSetupHelper.create( TckBackendHelper::createMultiTenancyBackendSetupStrategy ); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private StubSession tenant1SessionContext; private StubSession tenant2SessionContext; - @Before - public void setup() { + @BeforeEach + void setup() { StubMapping mapping = setupHelper.start().withIndex( index ).withMultiTenancy().setup(); tenant1SessionContext = mapping.session( TENANT_1 ); @@ -76,7 +76,7 @@ public void setup() { } @Test - public void search_only_returns_elements_of_the_selected_tenant() { + void search_only_returns_elements_of_the_selected_tenant() { StubMappingScope scope = index.createScope(); SearchQuery> query = scope.query( tenant1SessionContext ) @@ -103,7 +103,7 @@ public void search_only_returns_elements_of_the_selected_tenant() { // In Elasticsearch, we used to expect the user to provide the ID already prefixed with the tenant ID, which is wrong @Test @TestForIssue(jiraKey = "HSEARCH-3421") - public void id_predicate_takes_tenantId_into_account() { + void id_predicate_takes_tenantId_into_account() { StubMappingScope scope = index.createScope(); SearchQuery> query = scope.query( tenant1SessionContext ) @@ -128,7 +128,7 @@ public void id_predicate_takes_tenantId_into_account() { } @Test - public void search_on_nested_object_only_returns_elements_of_the_tenant() { + void search_on_nested_object_only_returns_elements_of_the_tenant() { StubMappingScope scope = index.createScope(); SearchQuery> query = scope.query( tenant1SessionContext ) @@ -159,7 +159,7 @@ public void search_on_nested_object_only_returns_elements_of_the_tenant() { } @Test - public void delete_only_deletes_elements_of_the_tenant() { + void delete_only_deletes_elements_of_the_tenant() { IndexIndexingPlan plan = index.createIndexingPlan( tenant2SessionContext ); StubMappingScope scope = index.createScope(); @@ -208,7 +208,7 @@ public void delete_only_deletes_elements_of_the_tenant() { } @Test - public void update_only_updates_elements_of_the_tenant() { + void update_only_updates_elements_of_the_tenant() { IndexIndexingPlan plan = index.createIndexingPlan( tenant2SessionContext ); StubMappingScope scope = index.createScope(); @@ -304,7 +304,7 @@ public void update_only_updates_elements_of_the_tenant() { } @Test - public void not_using_multi_tenancy_for_query_while_enabled_throws_exception() { + void not_using_multi_tenancy_for_query_while_enabled_throws_exception() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.query() @@ -317,7 +317,7 @@ public void not_using_multi_tenancy_for_query_while_enabled_throws_exception() { } @Test - public void not_using_multi_tenancy_for_add_while_enabled_throws_exception() { + void not_using_multi_tenancy_for_add_while_enabled_throws_exception() { assertThatThrownBy( () -> { IndexIndexingPlan plan = index.createIndexingPlan(); @@ -338,7 +338,7 @@ public void not_using_multi_tenancy_for_add_while_enabled_throws_exception() { } @Test - public void not_using_multi_tenancy_for_update_while_enabled_throws_exception() { + void not_using_multi_tenancy_for_update_while_enabled_throws_exception() { assertThatThrownBy( () -> { IndexIndexingPlan plan = index.createIndexingPlan(); @@ -359,7 +359,7 @@ public void not_using_multi_tenancy_for_update_while_enabled_throws_exception() } @Test - public void not_using_multi_tenancy_for_delete_while_enabled_throws_exception() { + void not_using_multi_tenancy_for_delete_while_enabled_throws_exception() { assertThatThrownBy( () -> { IndexIndexingPlan plan = index.createIndexingPlan(); plan.delete( referenceProvider( DOCUMENT_ID_1 ) ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/multitenancy/MultiTenancyMismatchIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/multitenancy/MultiTenancyMismatchIT.java index a011fb1acc4..cfc59579ba4 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/multitenancy/MultiTenancyMismatchIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/multitenancy/MultiTenancyMismatchIT.java @@ -14,32 +14,32 @@ import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubSession; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test that the backend correctly throws exception * when the mapper requires multi-tenancy but it is disabled in the backend, * and vice-versa. */ -public class MultiTenancyMismatchIT { +class MultiTenancyMismatchIT { public static final String TENANT_1 = "tenant_1"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); @Test - public void multiTenancyDisabled_requiredByTheMapper() { + void multiTenancyDisabled_requiredByTheMapper() { assertThatThrownBy( () -> setupHelper.start() .withIndex( index ) .withBackendProperty( "multi_tenancy.strategy", "none" ) @@ -56,7 +56,7 @@ public void multiTenancyDisabled_requiredByTheMapper() { } @Test - public void multiTenancyEnabled_disabledInTheMapper() { + void multiTenancyEnabled_disabledInTheMapper() { assertThatThrownBy( () -> setupHelper.start() .withIndex( index ) .withBackendProperty( "multi_tenancy.strategy", "discriminator" ) @@ -72,7 +72,7 @@ public void multiTenancyEnabled_disabledInTheMapper() { } @Test - public void using_multi_tenancy_for_query_while_disabled_throws_exception() { + void using_multi_tenancy_for_query_while_disabled_throws_exception() { StubMapping mapping = setupHelper.start().withIndex( index ).setup(); StubMappingScope scope = index.createScope(); @@ -90,7 +90,7 @@ public void using_multi_tenancy_for_query_while_disabled_throws_exception() { } @Test - public void using_multi_tenancy_for_add_while_disabled_throws_exception() { + void using_multi_tenancy_for_add_while_disabled_throws_exception() { StubMapping mapping = setupHelper.start().withIndex( index ).setup(); StubSession tenant1Session = mapping.session( TENANT_1 ); @@ -108,7 +108,7 @@ public void using_multi_tenancy_for_add_while_disabled_throws_exception() { } @Test - public void using_multi_tenancy_for_update_while_disabled_throws_exception() { + void using_multi_tenancy_for_update_while_disabled_throws_exception() { StubMapping mapping = setupHelper.start().withIndex( index ).setup(); StubSession tenant1Session = mapping.session( TENANT_1 ); @@ -126,7 +126,7 @@ public void using_multi_tenancy_for_update_while_disabled_throws_exception() { } @Test - public void using_multi_tenancy_for_delete_while_disabled_throws_exception() { + void using_multi_tenancy_for_delete_while_disabled_throws_exception() { StubMapping mapping = setupHelper.start().withIndex( index ).setup(); StubSession tenant1Session = mapping.session( TENANT_1 ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/SearchMultiIndexIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/SearchMultiIndexIT.java index f060dda2df8..354141d9641 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/SearchMultiIndexIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/SearchMultiIndexIT.java @@ -20,7 +20,7 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.search.query.SearchScroll; import org.hibernate.search.engine.search.query.SearchScrollResult; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; @@ -28,11 +28,11 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchMultiIndexIT { +class SearchMultiIndexIT { private static final String BACKEND_1 = "backend_1"; private static final String BACKEND_2 = "backend_2"; @@ -64,8 +64,8 @@ public class SearchMultiIndexIT { private static final String DOCUMENT_2_1_2 = "2_1_2"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index_1_1 = SimpleMappedIndex.of( IndexBinding_1_1::new ).backendName( BACKEND_1 ).name( "index_1_1" ); @@ -74,8 +74,8 @@ public class SearchMultiIndexIT { private final SimpleMappedIndex index_2_1 = SimpleMappedIndex.of( IndexBinding_2_1::new ).backendName( BACKEND_2 ).name( "index_2_1" );; - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start( BACKEND_1 ).withIndexes( index_1_1, index_1_2 ).setup(); setupHelper.start( BACKEND_2 ).withIndexes( index_2_1 ).setup(); @@ -89,7 +89,7 @@ public void setup() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3977") - public void search_singleIndex() { + void search_singleIndex() { SearchQuery query = index_1_1.query() .where( f -> f.match().field( "string" ).matching( STRING_1 ) ) .toQuery(); @@ -107,7 +107,7 @@ public void search_singleIndex() { } @Test - public void search_across_multiple_indexes() { + void search_across_multiple_indexes() { StubMappingScope scope = index_1_1.createScope( index_1_2 ); SearchQuery query = scope.query() @@ -121,7 +121,7 @@ public void search_across_multiple_indexes() { } @Test - public void sort_across_multiple_indexes() { + void sort_across_multiple_indexes() { StubMappingScope scope = index_1_1.createScope( index_1_2 ); SearchQuery query = scope.query() @@ -148,7 +148,7 @@ public void sort_across_multiple_indexes() { } @Test - public void projection_across_multiple_indexes() { + void projection_across_multiple_indexes() { StubMappingScope scope = index_1_1.createScope( index_1_2 ); SearchQuery query = scope.query() @@ -164,7 +164,7 @@ public void projection_across_multiple_indexes() { } @Test - public void field_in_one_index_only_is_supported() { + void field_in_one_index_only_is_supported() { StubMappingScope scope = index_1_1.createScope( index_1_2 ); // Predicate @@ -195,7 +195,7 @@ public void field_in_one_index_only_is_supported() { } @Test - public void unknown_field_throws_exception() { + void unknown_field_throws_exception() { StubMappingScope scope = index_1_1.createScope( index_1_2 ); // Predicate @@ -245,7 +245,7 @@ public void unknown_field_throws_exception() { } @Test - public void search_with_incompatible_types_throws_exception() { + void search_with_incompatible_types_throws_exception() { StubMappingScope scope = index_1_1.createScope( index_1_2 ); assertThatThrownBy( @@ -272,7 +272,7 @@ public void search_with_incompatible_types_throws_exception() { } @Test - public void search_across_backends_throws_exception() { + void search_across_backends_throws_exception() { assertThatThrownBy( () -> index_1_1.createScope( index_2_1 ), "search across multiple backends" diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/AggregationBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/AggregationBaseIT.java index ec40be842f5..09bc8f122d3 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/AggregationBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/AggregationBaseIT.java @@ -26,17 +26,17 @@ import org.hibernate.search.engine.search.aggregation.dsl.SearchAggregationFactory; import org.hibernate.search.engine.search.aggregation.dsl.SearchAggregationFactoryExtension; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class AggregationBaseIT { +class AggregationBaseIT { private static final String DOCUMENT_1 = "doc1"; private static final String DOCUMENT_2 = "doc2"; @@ -46,20 +46,20 @@ public class AggregationBaseIT { private static final String STRING_1 = "Irving"; private static final String STRING_2 = "Auster"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void extension() { + void extension() { StubMappingScope scope = index.createScope(); SearchQuery query; AggregationKey> aggregationKey = AggregationKey.of( "someAggregation" ); @@ -86,21 +86,21 @@ public void extension() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath() { + void toAbsolutePath() { assertThat( index.createScope().aggregation().toAbsolutePath( "string" ) ) .isEqualTo( "string" ); } @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_withRoot() { + void toAbsolutePath_withRoot() { assertThat( index.createScope().aggregation().withRoot( "flattened" ).toAbsolutePath( "string" ) ) .isEqualTo( "flattened.string" ); } @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_null() { + void toAbsolutePath_null() { assertThatThrownBy( () -> index.createScope().aggregation().toAbsolutePath( null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContaining( "'relativeFieldPath' must not be null" ); @@ -108,7 +108,7 @@ public void toAbsolutePath_null() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_withRoot_null() { + void toAbsolutePath_withRoot_null() { assertThatThrownBy( () -> index.createScope().aggregation().withRoot( "flattened" ).toAbsolutePath( null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContaining( "'relativeFieldPath' must not be null" ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/RangeAggregationSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/RangeAggregationSpecificsIT.java index bff77fdbb07..295eaae196d 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/RangeAggregationSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/RangeAggregationSpecificsIT.java @@ -12,7 +12,7 @@ import static org.hibernate.search.util.impl.integrationtest.common.NormalizationUtils.normalize; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatResult; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.Arrays; @@ -35,7 +35,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.data.Range; import org.hibernate.search.util.common.data.RangeBoundInclusion; @@ -43,49 +43,48 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests behavior specific to the range aggregation on supported field types. *

* Behavior common to all single-field aggregations is tested in {@link SingleFieldAggregationBaseIT}. */ -@RunWith(Parameterized.class) -public class RangeAggregationSpecificsIT { +class RangeAggregationSpecificsIT { private static final String AGGREGATION_NAME = "aggregationName"; - private static Set> supportedFieldTypes; - private static List> dataSets; + private static final Set> supportedFieldTypes = new LinkedHashSet<>(); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - supportedFieldTypes = new LinkedHashSet<>(); - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { AggregationDescriptor aggregationDescriptor = RangeAggregationDescriptor.INSTANCE; for ( FieldTypeDescriptor fieldType : FieldTypeDescriptor.getAll() ) { if ( aggregationDescriptor.getSingleFieldAggregationExpectations( fieldType ).isSupported() ) { supportedFieldTypes.add( fieldType ); DataSet dataSet = new DataSet<>( fieldType ); dataSets.add( dataSet ); - parameters.add( new Object[] { fieldType, dataSet } ); + parameters.add( Arguments.of( fieldType, dataSet ) ); } } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); for ( DataSet dataSet : dataSets ) { @@ -93,19 +92,10 @@ public static void setup() { } } - private final FieldTypeDescriptor fieldType; - private final DataSet dataSet; - private final List ascendingValues; - - public RangeAggregationSpecificsIT(FieldTypeDescriptor fieldType, DataSet dataSet) { - this.fieldType = fieldType; - this.dataSet = dataSet; - this.ascendingValues = dataSet.ascendingValues; - } - - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testRangeBelow") - public void rangeAtMost() { + void rangeAtMost(FieldTypeDescriptor fieldType, DataSet dataSet) { assumeNonCanonicalRangesSupported(); String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; @@ -115,7 +105,7 @@ public void rangeAtMost() { assertThatQuery( matchAllQuery() .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) - .range( Range.atMost( ascendingValues.get( 2 ) ) ) + .range( Range.atMost( dataSet.ascendingValues.get( 2 ) ) ) ) .routing( dataSet.name ) .toQuery() @@ -123,14 +113,15 @@ public void rangeAtMost() { .aggregation( aggregationKey, containsExactly( c -> { - c.accept( Range.atMost( ascendingValues.get( 2 ) ), 3L ); + c.accept( Range.atMost( dataSet.ascendingValues.get( 2 ) ), 3L ); } ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testRangeBelowExcludeLimit") - public void rangeLessThan() { + void rangeLessThan(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -138,7 +129,7 @@ public void rangeLessThan() { assertThatQuery( matchAllQuery() .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) - .range( Range.lessThan( ascendingValues.get( 2 ) ) ) + .range( Range.lessThan( dataSet.ascendingValues.get( 2 ) ) ) ) .routing( dataSet.name ) .toQuery() @@ -146,14 +137,15 @@ public void rangeLessThan() { .aggregation( aggregationKey, containsExactly( c -> { - c.accept( Range.canonical( null, ascendingValues.get( 2 ) ), 2L ); + c.accept( Range.canonical( null, dataSet.ascendingValues.get( 2 ) ), 2L ); } ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testRangeAbove") - public void rangeAtLeast() { + void rangeAtLeast(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -161,7 +153,7 @@ public void rangeAtLeast() { assertThatQuery( matchAllQuery() .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) - .range( Range.atLeast( ascendingValues.get( 3 ) ) ) + .range( Range.atLeast( dataSet.ascendingValues.get( 3 ) ) ) ) .routing( dataSet.name ) .toQuery() @@ -169,14 +161,15 @@ public void rangeAtLeast() { .aggregation( aggregationKey, containsExactly( c -> { - c.accept( Range.atLeast( ascendingValues.get( 3 ) ), 4L ); + c.accept( Range.atLeast( dataSet.ascendingValues.get( 3 ) ), 4L ); } ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testRangeAboveExcludeLimit") - public void rangeGreaterThan() { + void rangeGreaterThan(FieldTypeDescriptor fieldType, DataSet dataSet) { assumeNonCanonicalRangesSupported(); String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; @@ -186,7 +179,7 @@ public void rangeGreaterThan() { assertThatQuery( matchAllQuery() .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) - .range( Range.greaterThan( ascendingValues.get( 3 ) ) ) + .range( Range.greaterThan( dataSet.ascendingValues.get( 3 ) ) ) ) .routing( dataSet.name ) .toQuery() @@ -194,15 +187,16 @@ public void rangeGreaterThan() { .aggregation( aggregationKey, containsExactly( c -> { - c.accept( Range.greaterThan( ascendingValues.get( 3 ) ), 3L ); + c.accept( Range.greaterThan( dataSet.ascendingValues.get( 3 ) ), 3L ); } ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5( original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testRangeWithExcludeLimitsAtEachLevel") - public void rangesCanonical() { + void rangesCanonical(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -211,9 +205,9 @@ public void rangesCanonical() { matchAllQuery() .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) .ranges( Arrays.asList( - Range.canonical( null, ascendingValues.get( 3 ) ), - Range.canonical( ascendingValues.get( 3 ), ascendingValues.get( 5 ) ), - Range.canonical( ascendingValues.get( 5 ), null ) + Range.canonical( null, dataSet.ascendingValues.get( 3 ) ), + Range.canonical( dataSet.ascendingValues.get( 3 ), dataSet.ascendingValues.get( 5 ) ), + Range.canonical( dataSet.ascendingValues.get( 5 ), null ) ) ) ) .routing( dataSet.name ) @@ -222,16 +216,18 @@ public void rangesCanonical() { .aggregation( aggregationKey, containsExactly( c -> { - c.accept( Range.canonical( null, ascendingValues.get( 3 ) ), 3L ); - c.accept( Range.canonical( ascendingValues.get( 3 ), ascendingValues.get( 5 ) ), 2L ); - c.accept( Range.canonical( ascendingValues.get( 5 ), null ), 2L ); + c.accept( Range.canonical( null, dataSet.ascendingValues.get( 3 ) ), 3L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 3 ), dataSet.ascendingValues.get( 5 ) ), + 2L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 5 ), null ), 2L ); } ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testRangeBelowMiddleAbove") - public void rangesBetweenIncludingAllBounds() { + void rangesBetweenIncludingAllBounds(FieldTypeDescriptor fieldType, DataSet dataSet) { assumeNonCanonicalRangesSupported(); String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; @@ -243,10 +239,10 @@ public void rangesBetweenIncludingAllBounds() { .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) .ranges( Arrays.asList( Range.between( null, RangeBoundInclusion.INCLUDED, - ascendingValues.get( 2 ), RangeBoundInclusion.INCLUDED ), - Range.between( ascendingValues.get( 3 ), RangeBoundInclusion.INCLUDED, - ascendingValues.get( 4 ), RangeBoundInclusion.INCLUDED ), - Range.between( ascendingValues.get( 5 ), RangeBoundInclusion.INCLUDED, + dataSet.ascendingValues.get( 2 ), RangeBoundInclusion.INCLUDED ), + Range.between( dataSet.ascendingValues.get( 3 ), RangeBoundInclusion.INCLUDED, + dataSet.ascendingValues.get( 4 ), RangeBoundInclusion.INCLUDED ), + Range.between( dataSet.ascendingValues.get( 5 ), RangeBoundInclusion.INCLUDED, null, RangeBoundInclusion.INCLUDED ) ) ) ) @@ -258,16 +254,16 @@ public void rangesBetweenIncludingAllBounds() { containsExactly( c -> { c.accept( Range.between( null, RangeBoundInclusion.INCLUDED, - ascendingValues.get( 2 ), RangeBoundInclusion.INCLUDED ), + dataSet.ascendingValues.get( 2 ), RangeBoundInclusion.INCLUDED ), 3L ); c.accept( - Range.between( ascendingValues.get( 3 ), RangeBoundInclusion.INCLUDED, - ascendingValues.get( 4 ), RangeBoundInclusion.INCLUDED ), + Range.between( dataSet.ascendingValues.get( 3 ), RangeBoundInclusion.INCLUDED, + dataSet.ascendingValues.get( 4 ), RangeBoundInclusion.INCLUDED ), 2L ); c.accept( - Range.between( ascendingValues.get( 5 ), RangeBoundInclusion.INCLUDED, + Range.between( dataSet.ascendingValues.get( 5 ), RangeBoundInclusion.INCLUDED, null, RangeBoundInclusion.INCLUDED ), 2L ); @@ -277,8 +273,9 @@ public void rangesBetweenIncludingAllBounds() { } - @Test - public void rangesOverlap() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void rangesOverlap(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -287,9 +284,9 @@ public void rangesOverlap() { matchAllQuery() .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) .ranges( Arrays.asList( - Range.canonical( null, ascendingValues.get( 3 ) ), - Range.canonical( ascendingValues.get( 1 ), ascendingValues.get( 5 ) ), - Range.canonical( ascendingValues.get( 2 ), null ) + Range.canonical( null, dataSet.ascendingValues.get( 3 ) ), + Range.canonical( dataSet.ascendingValues.get( 1 ), dataSet.ascendingValues.get( 5 ) ), + Range.canonical( dataSet.ascendingValues.get( 2 ), null ) ) ) ) .routing( dataSet.name ) @@ -298,16 +295,18 @@ public void rangesOverlap() { .aggregation( aggregationKey, containsExactly( c -> { - c.accept( Range.canonical( null, ascendingValues.get( 3 ) ), 3L ); - c.accept( Range.canonical( ascendingValues.get( 1 ), ascendingValues.get( 5 ) ), 4L ); - c.accept( Range.canonical( ascendingValues.get( 2 ), null ), 5L ); + c.accept( Range.canonical( null, dataSet.ascendingValues.get( 3 ) ), 3L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 1 ), dataSet.ascendingValues.get( 5 ) ), + 4L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 2 ), null ), 5L ); } ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testRangeQueryWithNullToAndFrom") - public void rangeNull() { + void rangeNull(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; assertThatThrownBy( () -> index.createScope().aggregation().range() @@ -319,8 +318,9 @@ public void rangeNull() { .hasMessageContaining( "must not be null" ); } - @Test - public void rangesNull() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void rangesNull(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; assertThatThrownBy( () -> index.createScope().aggregation().range() @@ -332,14 +332,15 @@ public void rangesNull() { .hasMessageContaining( "must not be null" ); } - @Test - public void rangesContainingNull() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void rangesContainingNull(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; assertThatThrownBy( () -> index.createScope().aggregation().range() .field( fieldPath, fieldType.getJavaType() ) .ranges( Arrays.asList( - Range.canonical( ascendingValues.get( 0 ), ascendingValues.get( 1 ) ), + Range.canonical( dataSet.ascendingValues.get( 0 ), dataSet.ascendingValues.get( 1 ) ), null ) ) ) @@ -348,10 +349,11 @@ public void rangesContainingNull() { .hasMessageContaining( "must not be null" ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5( original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testUnsupportedRangeParameterTypeThrowsException") - public void fieldTypeSuperClass() { + void fieldTypeSuperClass(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; Class fieldTypeSuperClass = fieldType.getJavaType().getSuperclass(); @@ -369,10 +371,11 @@ public void fieldTypeSuperClass() { /** * Check that defining a predicate will affect the aggregation result. */ - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5( original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testRangeQueryForDoubleWithZeroCount") - public void predicate() { + void predicate(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -382,9 +385,9 @@ public void predicate() { .where( f -> f.id() .matchingAny( Arrays.asList( dataSet.name + "_document_1", dataSet.name + "_document_5" ) ) ) .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) - .range( null, ascendingValues.get( 2 ) ) - .range( ascendingValues.get( 2 ), ascendingValues.get( 5 ) ) - .range( ascendingValues.get( 5 ), null ) + .range( null, dataSet.ascendingValues.get( 2 ) ) + .range( dataSet.ascendingValues.get( 2 ), dataSet.ascendingValues.get( 5 ) ) + .range( dataSet.ascendingValues.get( 5 ), null ) ) .routing( dataSet.name ) .toQuery() @@ -393,10 +396,11 @@ public void predicate() { aggregationKey, // Only document 1 and 5 should be taken into account by the aggregation containsExactly( c -> { - c.accept( Range.canonical( null, ascendingValues.get( 2 ) ), 1L ); + c.accept( Range.canonical( null, dataSet.ascendingValues.get( 2 ) ), 1L ); // Ranges with 0 matching documents should still be returned - c.accept( Range.canonical( ascendingValues.get( 2 ), ascendingValues.get( 5 ) ), 0L ); - c.accept( Range.canonical( ascendingValues.get( 5 ), null ), 1L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 2 ), dataSet.ascendingValues.get( 5 ) ), + 0L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 5 ), null ), 1L ); } ) ); } @@ -404,8 +408,9 @@ public void predicate() { /** * Check that defining a limit and offset will not affect the aggregation result. */ - @Test - public void limitAndOffset() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void limitAndOffset(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -413,9 +418,9 @@ public void limitAndOffset() { assertThatResult( matchAllQuery() .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) - .range( null, ascendingValues.get( 2 ) ) - .range( ascendingValues.get( 2 ), ascendingValues.get( 5 ) ) - .range( ascendingValues.get( 5 ), null ) + .range( null, dataSet.ascendingValues.get( 2 ) ) + .range( dataSet.ascendingValues.get( 2 ), dataSet.ascendingValues.get( 5 ) ) + .range( dataSet.ascendingValues.get( 5 ), null ) ) .fetch( 3, 4 ) ) @@ -423,9 +428,10 @@ public void limitAndOffset() { aggregationKey, // All documents should be taken into account by the aggregation, even those excluded by the limit/offset containsExactly( c -> { - c.accept( Range.canonical( null, ascendingValues.get( 2 ) ), 2L ); - c.accept( Range.canonical( ascendingValues.get( 2 ), ascendingValues.get( 5 ) ), 3L ); - c.accept( Range.canonical( ascendingValues.get( 5 ), null ), 2L ); + c.accept( Range.canonical( null, dataSet.ascendingValues.get( 2 ) ), 2L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 2 ), dataSet.ascendingValues.get( 5 ) ), + 3L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 5 ), null ), 2L ); } ) ); } @@ -433,8 +439,9 @@ public void limitAndOffset() { /** * Check that defining overlapping ranges will work as expected. */ - @Test - public void rangeOverlap() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void rangeOverlap(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -442,13 +449,13 @@ public void rangeOverlap() { assertThatQuery( matchAllQuery() .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) - .range( ascendingValues.get( 0 ), null ) - .range( null, ascendingValues.get( 2 ) ) - .range( ascendingValues.get( 2 ), ascendingValues.get( 5 ) ) + .range( dataSet.ascendingValues.get( 0 ), null ) + .range( null, dataSet.ascendingValues.get( 2 ) ) + .range( dataSet.ascendingValues.get( 2 ), dataSet.ascendingValues.get( 5 ) ) .range( null, null ) - .range( ascendingValues.get( 0 ), ascendingValues.get( 7 ) ) - .range( ascendingValues.get( 5 ), null ) - .range( null, ascendingValues.get( 6 ) ) + .range( dataSet.ascendingValues.get( 0 ), dataSet.ascendingValues.get( 7 ) ) + .range( dataSet.ascendingValues.get( 5 ), null ) + .range( null, dataSet.ascendingValues.get( 6 ) ) ) .routing( dataSet.name ) .toQuery() @@ -456,13 +463,15 @@ public void rangeOverlap() { .aggregation( aggregationKey, containsExactly( c -> { - c.accept( Range.canonical( ascendingValues.get( 0 ), null ), 7L ); - c.accept( Range.canonical( null, ascendingValues.get( 2 ) ), 2L ); - c.accept( Range.canonical( ascendingValues.get( 2 ), ascendingValues.get( 5 ) ), 3L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 0 ), null ), 7L ); + c.accept( Range.canonical( null, dataSet.ascendingValues.get( 2 ) ), 2L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 2 ), dataSet.ascendingValues.get( 5 ) ), + 3L ); c.accept( Range.canonical( null, null ), 7L ); - c.accept( Range.canonical( ascendingValues.get( 0 ), ascendingValues.get( 7 ) ), 7L ); - c.accept( Range.canonical( ascendingValues.get( 5 ), null ), 2L ); - c.accept( Range.canonical( null, ascendingValues.get( 6 ) ), 6L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 0 ), dataSet.ascendingValues.get( 7 ) ), + 7L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 5 ), null ), 2L ); + c.accept( Range.canonical( null, dataSet.ascendingValues.get( 6 ) ), 6L ); } ) ); } @@ -470,8 +479,9 @@ public void rangeOverlap() { /** * Check that, by default, ranges are returned in the order they are defined. */ - @Test - public void order_asDefined() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void order_asDefined(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey, Long>> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -479,9 +489,9 @@ public void order_asDefined() { assertThatQuery( matchAllQuery() .aggregation( aggregationKey, f -> f.range().field( fieldPath, fieldType.getJavaType() ) - .range( null, ascendingValues.get( 2 ) ) - .range( ascendingValues.get( 2 ), ascendingValues.get( 5 ) ) - .range( ascendingValues.get( 5 ), null ) + .range( null, dataSet.ascendingValues.get( 2 ) ) + .range( dataSet.ascendingValues.get( 2 ), dataSet.ascendingValues.get( 5 ) ) + .range( dataSet.ascendingValues.get( 5 ), null ) ) .routing( dataSet.name ) .toQuery() @@ -489,17 +499,18 @@ public void order_asDefined() { .aggregation( aggregationKey, containsExactly( c -> { - c.accept( Range.canonical( null, ascendingValues.get( 2 ) ), 2L ); - c.accept( Range.canonical( ascendingValues.get( 2 ), ascendingValues.get( 5 ) ), 3L ); - c.accept( Range.canonical( ascendingValues.get( 5 ), null ), 2L ); + c.accept( Range.canonical( null, dataSet.ascendingValues.get( 2 ) ), 2L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 2 ), dataSet.ascendingValues.get( 5 ) ), + 3L ); + c.accept( Range.canonical( dataSet.ascendingValues.get( 5 ), null ), 2L ); } ) ); } private void assumeNonCanonicalRangesSupported() { assumeTrue( - "Non-canonical ranges are not supported for aggregations with this backend", - TckConfiguration.get().getBackendFeatures().nonCanonicalRangeInAggregations() + TckConfiguration.get().getBackendFeatures().nonCanonicalRangeInAggregations(), + "Non-canonical ranges are not supported for aggregations with this backend" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationBaseIT.java index 4209f835bb7..2b7c665cf72 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationBaseIT.java @@ -9,7 +9,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.Arrays; @@ -35,36 +35,32 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.operations.expectations.SupportedSingleFieldAggregationExpectations; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests basic behavior common to all single-field aggregations (range, terms, ...) * on supported types. */ -@RunWith(Parameterized.class) -public class SingleFieldAggregationBaseIT { +class SingleFieldAggregationBaseIT { private static final String AGGREGATION_NAME = "aggregationName"; - private static Set> supportedFieldTypes; - private static List> dataSets; + private static final Set> supportedFieldTypes = new LinkedHashSet<>(); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0} - {1}") - public static Object[][] parameters() { - supportedFieldTypes = new LinkedHashSet<>(); - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { for ( AggregationDescriptor aggregationDescriptor : AggregationDescriptor.getAll() ) { for ( FieldTypeDescriptor fieldTypeDescriptor : FieldTypeDescriptor.getAll() ) { Optional> expectations = @@ -74,16 +70,19 @@ public static Object[][] parameters() { supportedFieldTypes.add( fieldTypeDescriptor ); DataSet dataSet = new DataSet<>( expectations.get(), fieldStructure ); dataSets.add( dataSet ); - parameters.add( new Object[] { expectations.get(), fieldStructure, dataSet } ); + parameters.add( Arguments.of( expectations.get(), fieldStructure, dataSet ) ); } } } } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final Function bindingFactory = root -> SingleFieldIndexBinding.create( root, supportedFieldTypes, c -> c.aggregable( Aggregable.YES ) ); @@ -96,8 +95,8 @@ public static Object[][] parameters() { private static final SimpleMappedIndex nullOnlyIndex = SimpleMappedIndex.of( bindingFactory ).name( "NullOnly" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( mainIndex, emptyIndex, nullOnlyIndex ).setup(); BulkIndexer mainIndexer = mainIndex.bulkIndexer(); @@ -109,20 +108,8 @@ public static void setup() { mainIndexer.join( nullOnlyIndexer ); } - private final SupportedSingleFieldAggregationExpectations expectations; - private final FieldTypeDescriptor fieldType; - private final TestedFieldStructure fieldStructure; - private final DataSet dataSet; - - public SingleFieldAggregationBaseIT(SupportedSingleFieldAggregationExpectations expectations, - TestedFieldStructure fieldStructure, DataSet dataSet) { - this.expectations = expectations; - this.fieldType = expectations.fieldType(); - this.fieldStructure = fieldStructure; - this.dataSet = dataSet; - } - - @Test + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-726", "HSEARCH-900", @@ -145,24 +132,34 @@ public SingleFieldAggregationBaseIT(SupportedSingleFieldAggregationExpectations< "org.hibernate.search.test.query.facet.ManyToOneFacetingTest", "org.hibernate.search.test.query.facet.MultiValuedFacetingTest" }) - public void simple() { - testValidAggregation( getSimpleScenario(), mainIndex.createScope(), - getFieldPath( mainIndex.binding() ), getFilterOrNull( mainIndex.binding() ) ); + void simple(SupportedSingleFieldAggregationExpectations expectations, + TestedFieldStructure fieldStructure, DataSet dataSet) { + testValidAggregation( getSimpleScenario( expectations, fieldStructure ), mainIndex.createScope(), + getFieldPath( mainIndex.binding(), fieldStructure, expectations.fieldType() ), + getFilterOrNull( mainIndex.binding(), + fieldStructure + ), dataSet + ); } - @Test - public void aggregationObject() { + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void aggregationObject(SupportedSingleFieldAggregationExpectations expectations, + TestedFieldStructure fieldStructure, DataSet dataSet) { // Need a separate method to handle the scenario generics - doTest_aggregationObject( getSimpleScenario() ); + doTest_aggregationObject( getSimpleScenario( expectations, fieldStructure ), dataSet, fieldStructure, + expectations.fieldType() + ); } - private void doTest_aggregationObject(AggregationScenario scenario) { + private void doTest_aggregationObject(AggregationScenario scenario, DataSet dataSet, + TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldPath( mainIndex.binding() ); + String fieldPath = getFieldPath( mainIndex.binding(), fieldStructure, fieldType ); AggregationKey aggregationKey = AggregationKey.of( AGGREGATION_NAME ); SearchAggregation aggregation = - scenario.setup( scope.aggregation(), fieldPath, getFilterOrNull( mainIndex.binding() ) ) + scenario.setup( scope.aggregation(), fieldPath, getFilterOrNull( mainIndex.binding(), fieldStructure ) ) .toAggregation(); assertThatQuery( @@ -178,17 +175,20 @@ private void doTest_aggregationObject(AggregationScenario scenario) { ); } - @Test + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-1968" }) @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.NoQueryResultsFacetingTest") - public void noMatch() { - String fieldPath = getFieldPath( mainIndex.binding() ); + void noMatch(SupportedSingleFieldAggregationExpectations expectations, + TestedFieldStructure fieldStructure, DataSet dataSet) { + String fieldPath = getFieldPath( mainIndex.binding(), fieldStructure, expectations.fieldType() ); AggregationScenario scenario = expectations.withoutMatch(); testValidAggregation( scenario, mainIndex.createScope(), f -> f.id().matching( "none" ), // Don't match any document - (f, e) -> e.setup( f, fieldPath, getFilterOrNull( mainIndex.binding() ) ) + (f, e) -> e.setup( f, fieldPath, getFilterOrNull( mainIndex.binding(), fieldStructure ) ), + dataSet ); } @@ -196,18 +196,21 @@ public void noMatch() { * Test behavior when aggregating on an index with no value for the targeted field * because there is no document in the mainIndex. */ - @Test + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-2955", "HSEARCH-745" }) @PortedFromSearch5(original = { "org.hibernate.search.test.facet.NoIndexedValueFacetingTest", "org.hibernate.search.test.query.facet.EdgeCaseFacetTest" }) - public void emptyIndex() { - String fieldPath = getFieldPath( emptyIndex.binding() ); + void emptyIndex(SupportedSingleFieldAggregationExpectations expectations, + TestedFieldStructure fieldStructure, DataSet dataSet) { + String fieldPath = getFieldPath( emptyIndex.binding(), fieldStructure, expectations.fieldType() ); AggregationScenario scenario = expectations.withoutMatch(); testValidAggregation( - scenario, emptyIndex.createScope(), fieldPath, null + scenario, emptyIndex.createScope(), fieldPath, null, + dataSet ); } @@ -215,49 +218,60 @@ public void emptyIndex() { * Test behavior when aggregating on an index with no value for the targeted field * because no document has a non-null value for this field. */ - @Test + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-2955") @PortedFromSearch5(original = "org.hibernate.search.test.facet.NoIndexedValueFacetingTest") - public void nullOnlyIndex() { - String fieldPath = getFieldPath( nullOnlyIndex.binding() ); + void nullOnlyIndex(SupportedSingleFieldAggregationExpectations expectations, + TestedFieldStructure fieldStructure, DataSet dataSet) { + String fieldPath = getFieldPath( nullOnlyIndex.binding(), fieldStructure, expectations.fieldType() ); AggregationScenario scenario = expectations.withoutMatch(); testValidAggregation( - scenario, nullOnlyIndex.createScope(), fieldPath, null + scenario, nullOnlyIndex.createScope(), fieldPath, null, + dataSet ); } - @Test + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void factoryWithRoot() { + void factoryWithRoot(SupportedSingleFieldAggregationExpectations expectations, + TestedFieldStructure fieldStructure, DataSet dataSet) { AbstractObjectBinding parentObjectBinding = mainIndex.binding().getParentObject( fieldStructure ); - assumeTrue( "This test is only relevant when the field is located on an object field", - parentObjectBinding.absolutePath != null ); + assumeTrue( + parentObjectBinding.absolutePath != null, + "This test is only relevant when the field is located on an object field" + ); testValidAggregation( - getSimpleScenario(), mainIndex.createScope(), + getSimpleScenario( expectations, fieldStructure ), mainIndex.createScope(), f -> f.matchAll(), (f, e) -> e.setup( f.withRoot( parentObjectBinding.absolutePath ), - parentObjectBinding.getRelativeFieldName( fieldStructure, fieldType ), - getFilterOrNull( AbstractObjectBinding.DISCRIMINATOR_FIELD_NAME ) - ) + parentObjectBinding.getRelativeFieldName( fieldStructure, expectations.fieldType() ), + getFilterOrNull( AbstractObjectBinding.DISCRIMINATOR_FIELD_NAME, fieldStructure ) + ), + dataSet ); } private void testValidAggregation(AggregationScenario scenario, StubMappingScope scope, - String fieldPath, Function filterOrNull) { + String fieldPath, Function filterOrNull, + DataSet dataSet) { testValidAggregation( scenario, scope, f -> f.matchAll(), - (f, e) -> e.setup( f, fieldPath, filterOrNull ) + (f, e) -> e.setup( f, fieldPath, filterOrNull ), + dataSet ); } private void testValidAggregation(AggregationScenario scenario, StubMappingScope scope, Function predicateContributor, - BiFunction, AggregationFinalStep> aggregationContributor) { + BiFunction, AggregationFinalStep> aggregationContributor, + DataSet dataSet) { AggregationKey aggregationKey = AggregationKey.of( AGGREGATION_NAME ); assertThatQuery( scope.query() @@ -272,7 +286,8 @@ private void testValidAggregation(AggregationScenario scenario, StubMappi ); } - private AggregationScenario getSimpleScenario() { + private AggregationScenario getSimpleScenario(SupportedSingleFieldAggregationExpectations expectations, + TestedFieldStructure fieldStructure) { AggregationScenario scenario; if ( fieldStructure.isSingleValued() ) { scenario = expectations.simple(); @@ -283,17 +298,18 @@ private AggregationScenario getSimpleScenario() { return scenario; } - private String getFieldPath(SingleFieldIndexBinding indexBinding) { + private String getFieldPath(SingleFieldIndexBinding indexBinding, TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType) { return indexBinding.getFieldPath( fieldStructure, fieldType ); } private Function getFilterOrNull( - SingleFieldIndexBinding binding) { - return getFilterOrNull( binding.getDiscriminatorFieldPath( fieldStructure ) ); + SingleFieldIndexBinding binding, TestedFieldStructure fieldStructure) { + return getFilterOrNull( binding.getDiscriminatorFieldPath( fieldStructure ), fieldStructure ); } private Function getFilterOrNull( - String discriminatorPath) { + String discriminatorPath, TestedFieldStructure fieldStructure) { if ( fieldStructure.isInNested() ) { return pf -> pf.match() .field( discriminatorPath ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationFilteringSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationFilteringSpecificsIT.java index c1856c9f8eb..ac3c5d43515 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationFilteringSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationFilteringSpecificsIT.java @@ -25,70 +25,63 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.operations.expectations.SupportedSingleFieldAggregationExpectations; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests behavior related to * {@link org.hibernate.search.engine.search.aggregation.dsl.AggregationFilterStep#filter(Function) filtering} * that is not tested in {@link SingleFieldAggregationBaseIT}. */ -@RunWith(Parameterized.class) -public class SingleFieldAggregationFilteringSpecificsIT { +class SingleFieldAggregationFilteringSpecificsIT { - private static Set> supportedFieldTypes; + private static final Set> supportedFieldTypes = new LinkedHashSet<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - supportedFieldTypes = new LinkedHashSet<>(); - List parameters = new ArrayList<>(); + static { for ( AggregationDescriptor aggregationDescriptor : AggregationDescriptor.getAll() ) { for ( FieldTypeDescriptor fieldType : FieldTypeDescriptor.getAll() ) { Optional> expectations = aggregationDescriptor.getSingleFieldAggregationExpectations( fieldType ).getSupported(); if ( expectations.isPresent() ) { supportedFieldTypes.add( fieldType ); - parameters.add( new Object[] { expectations.get() } ); + parameters.add( Arguments.of( expectations.get() ) ); } } } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( mainIndex ).setup(); } - private final SupportedSingleFieldAggregationExpectations expectations; - private final FieldTypeDescriptor fieldType; - - public SingleFieldAggregationFilteringSpecificsIT(SupportedSingleFieldAggregationExpectations expectations) { - this.expectations = expectations; - this.fieldType = expectations.fieldType(); - } - - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3881") - public void nonNested() { + void nonNested(SupportedSingleFieldAggregationExpectations expectations) { StubMappingScope scope = mainIndex.createScope(); AggregationScenario scenario = expectations.simple(); String fieldPath = mainIndex.binding().flattenedObject.relativeFieldName + "." - + mainIndex.binding().flattenedObject.fieldModels.get( fieldType ).relativeFieldName; + + mainIndex.binding().flattenedObject.fieldModels.get( expectations.fieldType() ).relativeFieldName; assertThatThrownBy( () -> scenario.setup( scope.aggregation(), fieldPath, pf -> pf.exists().field( fieldPath ) ) @@ -100,14 +93,15 @@ public void nonNested() { ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3881") - public void invalidNestedPath_parent() { + void invalidNestedPath_parent(SupportedSingleFieldAggregationExpectations expectations) { StubMappingScope scope = mainIndex.createScope(); AggregationScenario scenario = expectations.simple(); String fieldPath = mainIndex.binding().nestedObject1.relativeFieldName + "." - + mainIndex.binding().nestedObject1.fieldModels.get( fieldType ).relativeFieldName; - String fieldInParentPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + + mainIndex.binding().nestedObject1.fieldModels.get( expectations.fieldType() ).relativeFieldName; + String fieldInParentPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; assertThatThrownBy( () -> scenario.setup( scope.aggregation(), fieldPath, pf -> pf.exists().field( fieldInParentPath ) ) @@ -120,15 +114,16 @@ public void invalidNestedPath_parent() { + " are allowed here." ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3881") - public void invalidNestedPath_sibling() { + void invalidNestedPath_sibling(SupportedSingleFieldAggregationExpectations expectations) { StubMappingScope scope = mainIndex.createScope(); AggregationScenario scenario = expectations.simple(); String fieldPath = mainIndex.binding().nestedObject1.relativeFieldName + "." - + mainIndex.binding().nestedObject1.fieldModels.get( fieldType ).relativeFieldName; + + mainIndex.binding().nestedObject1.fieldModels.get( expectations.fieldType() ).relativeFieldName; String fieldInSiblingPath = mainIndex.binding().nestedObject2.relativeFieldName + "." - + mainIndex.binding().nestedObject2.fieldModels.get( fieldType ).relativeFieldName; + + mainIndex.binding().nestedObject2.fieldModels.get( expectations.fieldType() ).relativeFieldName; assertThatThrownBy( () -> scenario.setup( scope.aggregation(), fieldPath, pf -> pf.exists().field( fieldInSiblingPath ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationInvalidFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationInvalidFieldIT.java index 3a158bd3cf6..1ef36e37400 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationInvalidFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationInvalidFieldIT.java @@ -19,62 +19,52 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.operations.AggregationDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.operations.expectations.AggregationScenario; import org.hibernate.search.integrationtest.backend.tck.testsupport.operations.expectations.SupportedSingleFieldAggregationExpectations; -import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.IntegerFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TypeAssertionHelper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests behavior of all single-field aggregations (range, terms, ...) * when invalid fields are targeted. */ -@RunWith(Parameterized.class) -public class SingleFieldAggregationInvalidFieldIT { +class SingleFieldAggregationInvalidFieldIT { private static final IntegerFieldTypeDescriptor FIELD_TYPE = IntegerFieldTypeDescriptor.INSTANCE; - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - List parameters = new ArrayList<>(); + public static List params() { + List parameters = new ArrayList<>(); for ( AggregationDescriptor aggregationDescriptor : AggregationDescriptor.getAll() ) { Optional> expectations = aggregationDescriptor.getSingleFieldAggregationExpectations( FIELD_TYPE ).getSupported(); - parameters.add( new Object[] { expectations.get() } ); + parameters.add( Arguments.of( expectations.get() ) ); } - return parameters.toArray( new Object[0][] ); + return parameters; } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final SupportedSingleFieldAggregationExpectations expectations; - private final FieldTypeDescriptor fieldType; - - public SingleFieldAggregationInvalidFieldIT(SupportedSingleFieldAggregationExpectations expectations) { - this.expectations = expectations; - this.fieldType = expectations.fieldType(); - } - - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5( original = "org.hibernate.search.test.query.facet.FacetUnknownFieldFailureTest.testUnknownFieldNameThrowsException") - public void unknownField() { + void unknownField(SupportedSingleFieldAggregationExpectations expectations) { String fieldPath = "unknownField"; AggregationScenario scenario = expectations.simple(); @@ -86,9 +76,10 @@ public void unknownField() { .hasMessageContaining( index.name() ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.SimpleFacetingTest.testNullFieldNameThrowsException") - public void nullFieldPath() { + void nullFieldPath(SupportedSingleFieldAggregationExpectations expectations) { // Try to pass a "null" field type AggregationScenario scenario = expectations.simple(); @@ -98,11 +89,13 @@ public void nullFieldPath() { .hasMessageContaining( "must not be null" ); } - @Test - public void objectField_nested() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void objectField_nested(SupportedSingleFieldAggregationExpectations expectations) { String fieldPath = index.binding().nestedObject.relativeFieldName; - AggregationScenario scenario = expectations.withFieldType( TypeAssertionHelper.identity( fieldType ) ); + AggregationScenario scenario = + expectations.withFieldType( TypeAssertionHelper.identity( expectations.fieldType() ) ); assertThatThrownBy( () -> scenario.setup( index.createScope().aggregation(), fieldPath ) ) .isInstanceOf( SearchException.class ) @@ -110,11 +103,13 @@ public void objectField_nested() { "Cannot use 'aggregation:" + expectations.aggregationName() + "' on field '" + fieldPath + "'" ); } - @Test - public void objectField_flattened() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void objectField_flattened(SupportedSingleFieldAggregationExpectations expectations) { String fieldPath = index.binding().flattenedObject.relativeFieldName; - AggregationScenario scenario = expectations.withFieldType( TypeAssertionHelper.identity( fieldType ) ); + AggregationScenario scenario = + expectations.withFieldType( TypeAssertionHelper.identity( expectations.fieldType() ) ); assertThatThrownBy( () -> scenario.setup( index.createScope().aggregation(), fieldPath ) ) .isInstanceOf( SearchException.class ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationTypeCheckingAndConversionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationTypeCheckingAndConversionIT.java index 3d583a24447..dade0273460 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationTypeCheckingAndConversionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationTypeCheckingAndConversionIT.java @@ -46,7 +46,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TypeAssertionHelper; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; @@ -54,30 +54,26 @@ import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests behavior related to type checking and type conversion of DSL arguments * for all single-field aggregations (range, terms, ...) * on supported types. */ -@RunWith(Parameterized.class) -public class SingleFieldAggregationTypeCheckingAndConversionIT { +class SingleFieldAggregationTypeCheckingAndConversionIT { private static final String AGGREGATION_NAME = "aggregationName"; - private static Set> supportedFieldTypes; - private static List> dataSets; + private static final Set> supportedFieldTypes = new LinkedHashSet<>(); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - supportedFieldTypes = new LinkedHashSet<>(); - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { for ( AggregationDescriptor aggregationDescriptor : AggregationDescriptor.getAll() ) { for ( FieldTypeDescriptor fieldTypeDescriptor : FieldTypeDescriptor.getAll() ) { Optional> expectations = @@ -86,15 +82,18 @@ public static Object[][] parameters() { supportedFieldTypes.add( fieldTypeDescriptor ); DataSet dataSet = new DataSet<>( expectations.get() ); dataSets.add( dataSet ); - parameters.add( new Object[] { expectations.get(), dataSet } ); + parameters.add( Arguments.of( expectations.get(), dataSet ) ); } } } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "Main" ); @@ -105,8 +104,8 @@ public static Object[][] parameters() { private static final SimpleMappedIndex incompatibleIndex = SimpleMappedIndex.of( IncompatibleIndexBinding::new ).name( "Incompatible" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( mainIndex, @@ -121,24 +120,16 @@ public static void setup() { } } - private final SupportedSingleFieldAggregationExpectations expectations; - private final FieldTypeDescriptor fieldType; - private final DataSet dataSet; - - public SingleFieldAggregationTypeCheckingAndConversionIT(SupportedSingleFieldAggregationExpectations expectations, + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void aggregationObject_reuse_onScopeTargetingSameIndexes(SupportedSingleFieldAggregationExpectations expectations, DataSet dataSet) { - this.expectations = expectations; - this.fieldType = expectations.fieldType(); - this.dataSet = dataSet; - } - - @Test - public void aggregationObject_reuse_onScopeTargetingSameIndexes() { // Need a separate method to handle the scenario generics - doTest_aggregationObject_reuse_onScopeTargetingSameIndexes( expectations.simple() ); + doTest_aggregationObject_reuse_onScopeTargetingSameIndexes( expectations.simple(), expectations.fieldType(), dataSet ); } - private void doTest_aggregationObject_reuse_onScopeTargetingSameIndexes(AggregationScenario scenario) { + private void doTest_aggregationObject_reuse_onScopeTargetingSameIndexes(AggregationScenario scenario, + FieldTypeDescriptor fieldType, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -186,13 +177,17 @@ private void doTest_aggregationObject_reuse_onScopeTargetingSameIndexes(Aggr ); } - @Test - public void aggregationObject_reuse_onScopeTargetingDifferentIndexes() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void aggregationObject_reuse_onScopeTargetingDifferentIndexes( + SupportedSingleFieldAggregationExpectations expectations, DataSet dataSet) { // Need a separate method to handle the scenario generics - doTest_aggregationObject_reuse_onScopeTargetingDifferentIndexes( expectations.simple() ); + doTest_aggregationObject_reuse_onScopeTargetingDifferentIndexes( expectations.simple(), expectations.fieldType(), + dataSet ); } - private void doTest_aggregationObject_reuse_onScopeTargetingDifferentIndexes(AggregationScenario scenario) { + private void doTest_aggregationObject_reuse_onScopeTargetingDifferentIndexes(AggregationScenario scenario, + FieldTypeDescriptor fieldType, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -226,11 +221,13 @@ private void doTest_aggregationObject_reuse_onScopeTargetingDifferentIndexes "the given aggregation was built from a scope targeting indexes ", mainIndex.name() ); } - @Test - public void invalidFieldType_conversionEnabled() { - String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidFieldType_conversionEnabled(SupportedSingleFieldAggregationExpectations expectations, + DataSet dataSet) { + String fieldPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; - FieldTypeDescriptor wrongType = FieldTypeDescriptor.getIncompatible( fieldType ); + FieldTypeDescriptor wrongType = FieldTypeDescriptor.getIncompatible( expectations.fieldType() ); AggregationScenario scenario = expectations.withFieldType( TypeAssertionHelper.wrongType( wrongType ) ); @@ -238,16 +235,18 @@ public void invalidFieldType_conversionEnabled() { .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid type", "'" + wrongType.getJavaType().getName() + "'", - "Expected '" + fieldType.getJavaType().getName() + "'", + "Expected '" + expectations.fieldType().getJavaType().getName() + "'", "field '" + fieldPath + "'" ); } - @Test - public void invalidFieldType_conversionDisabled() { - String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidFieldType_conversionDisabled(SupportedSingleFieldAggregationExpectations expectations, + DataSet dataSet) { + String fieldPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; - FieldTypeDescriptor wrongType = FieldTypeDescriptor.getIncompatible( fieldType ); + FieldTypeDescriptor wrongType = FieldTypeDescriptor.getIncompatible( expectations.fieldType() ); AggregationScenario scenario = expectations.withFieldType( TypeAssertionHelper.wrongType( wrongType ) ); @@ -257,14 +256,15 @@ public void invalidFieldType_conversionDisabled() { .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid type", "'" + wrongType.getJavaType().getName() + "'", - "Expected '" + fieldType.getJavaType().getName() + "'", + "Expected '" + expectations.fieldType().getJavaType().getName() + "'", "field '" + fieldPath + "'" ); } - @Test - public void nullFieldType() { - String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void nullFieldType(SupportedSingleFieldAggregationExpectations expectations, DataSet dataSet) { + String fieldPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; // Try to pass a "null" field type AggregationScenario scenario = expectations.withFieldType( TypeAssertionHelper.nullType() ); @@ -278,18 +278,19 @@ public void nullFieldType() { /** * Test that mentioning the same aggregation twice with different keys works as expected. */ - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.SimpleFacetingTest.testMultipleFacets") - public void duplicated_differentKeys() { - String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + void duplicated_differentKeys(SupportedSingleFieldAggregationExpectations expectations, DataSet dataSet) { + String fieldPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.simple(); // A separate method is needed in order to write type-safe code - doTestDuplicatedDifferentKeys( fieldPath, scenario ); + doTestDuplicatedDifferentKeys( fieldPath, scenario, dataSet ); } - private void doTestDuplicatedDifferentKeys(String fieldPath, AggregationScenario scenario) { + private void doTestDuplicatedDifferentKeys(String fieldPath, AggregationScenario scenario, DataSet dataSet) { AggregationKey key1 = AggregationKey.of( "aggregationName1" ); AggregationKey key2 = AggregationKey.of( "aggregationName2" ); @@ -313,9 +314,10 @@ private void doTestDuplicatedDifferentKeys(String fieldPath, AggregationScen /** * Test that mentioning the same aggregation twice with the same key throws an exception as expected. */ - @Test - public void duplicated_sameKey() { - String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void duplicated_sameKey(SupportedSingleFieldAggregationExpectations expectations, DataSet dataSet) { + String fieldPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.simple(); @@ -334,14 +336,17 @@ private void doTestDuplicatedSameKey(String fieldPath, AggregationScenario expectations, DataSet dataSet) { + String fieldPath = + mainIndex.binding().fieldWithAggregationDisabledModels.get( expectations.fieldType() ).relativeFieldName; - AggregationScenario scenario = expectations.withFieldType( TypeAssertionHelper.identity( fieldType ) ); + AggregationScenario scenario = + expectations.withFieldType( TypeAssertionHelper.identity( expectations.fieldType() ) ); assertThatThrownBy( () -> scenario.setup( mainIndex.createScope().aggregation(), fieldPath ) ) .isInstanceOf( SearchException.class ) @@ -351,77 +356,93 @@ public void aggregationsDisabled() { ); } - @Test - public void withConverter_conversionEnabled() { - String fieldPath = mainIndex.binding().fieldWithConverterModels.get( fieldType ).relativeFieldName; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withConverter_conversionEnabled(SupportedSingleFieldAggregationExpectations expectations, + DataSet dataSet) { + String fieldPath = mainIndex.binding().fieldWithConverterModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.withFieldType( - TypeAssertionHelper.wrapper( fieldType ) + TypeAssertionHelper.wrapper( expectations.fieldType() ) ); testValidAggregation( - scenario, mainIndex.createScope(), fieldPath + scenario, mainIndex.createScope(), fieldPath, + dataSet ); } - @Test - public void withConverter_conversionDisabled() { - String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withConverter_conversionDisabled(SupportedSingleFieldAggregationExpectations expectations, + DataSet dataSet) { + String fieldPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.simple(); testValidAggregationWithConverterSetting( - scenario, mainIndex.createScope(), fieldPath, ValueConvert.NO + scenario, mainIndex.createScope(), fieldPath, ValueConvert.NO, + dataSet ); } - @Test - public void withConverter_invalidFieldType() { - String fieldPath = mainIndex.binding().fieldWithConverterModels.get( fieldType ).relativeFieldName; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withConverter_invalidFieldType(SupportedSingleFieldAggregationExpectations expectations, + DataSet dataSet) { + String fieldPath = mainIndex.binding().fieldWithConverterModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.simple(); assertThatThrownBy( () -> scenario.setup( mainIndex.createScope().aggregation(), fieldPath ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( - "Invalid type", "'" + fieldType.getJavaType().getName() + "'", + "Invalid type", "'" + expectations.fieldType().getJavaType().getName() + "'", "Expected '" + ValueWrapper.class.getName() + "'", "field '" + fieldPath + "'" ); } - @Test - public void multiIndex_withCompatibleIndex_noConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withCompatibleIndex_noConverter(SupportedSingleFieldAggregationExpectations expectations, + DataSet dataSet) { StubMappingScope scope = mainIndex.createScope( compatibleIndex ); - String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + String fieldPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.onMainAndOtherIndex(); testValidAggregation( - scenario, scope, fieldPath + scenario, scope, fieldPath, + dataSet ); } - @Test - public void multiIndex_withCompatibleIndex_conversionEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withCompatibleIndex_conversionEnabled(SupportedSingleFieldAggregationExpectations expectations, + DataSet dataSet) { StubMappingScope scope = mainIndex.createScope( compatibleIndex ); - String fieldPath = mainIndex.binding().fieldWithConverterModels.get( fieldType ).relativeFieldName; + String fieldPath = mainIndex.binding().fieldWithConverterModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.withFieldTypeOnMainAndOtherIndex( - TypeAssertionHelper.wrapper( fieldType ) + TypeAssertionHelper.wrapper( expectations.fieldType() ) ); testValidAggregation( - scenario, scope, fieldPath + scenario, scope, fieldPath, + dataSet ); } - @Test - public void multiIndex_withRawFieldCompatibleIndex_conversionEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withRawFieldCompatibleIndex_conversionEnabled( + SupportedSingleFieldAggregationExpectations expectations, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope( rawFieldCompatibleIndex ); - String fieldPath = mainIndex.binding().fieldWithConverterModels.get( fieldType ).relativeFieldName; + String fieldPath = mainIndex.binding().fieldWithConverterModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.withFieldTypeOnMainAndOtherIndex( - TypeAssertionHelper.wrapper( fieldType ) + TypeAssertionHelper.wrapper( expectations.fieldType() ) ); assertThatThrownBy( () -> scenario.setup( scope.aggregation(), fieldPath ) ) @@ -432,23 +453,28 @@ public void multiIndex_withRawFieldCompatibleIndex_conversionEnabled() { ); } - @Test - public void multiIndex_withRawFieldCompatibleIndex_conversionDisabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withRawFieldCompatibleIndex_conversionDisabled( + SupportedSingleFieldAggregationExpectations expectations, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope( rawFieldCompatibleIndex ); - String fieldPath = mainIndex.binding().fieldWithConverterModels.get( fieldType ).relativeFieldName; + String fieldPath = mainIndex.binding().fieldWithConverterModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.onMainAndOtherIndex(); testValidAggregationWithConverterSetting( - scenario, scope, fieldPath, ValueConvert.NO + scenario, scope, fieldPath, ValueConvert.NO, + dataSet ); } - @Test - public void multiIndex_withIncompatibleIndex_conversionEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex_conversionEnabled(SupportedSingleFieldAggregationExpectations expectations, + DataSet dataSet) { StubMappingScope scope = mainIndex.createScope( incompatibleIndex ); - String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + String fieldPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.simple(); @@ -460,11 +486,13 @@ public void multiIndex_withIncompatibleIndex_conversionEnabled() { ); } - @Test - public void multiIndex_withIncompatibleIndex_conversionDisabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex_conversionDisabled(SupportedSingleFieldAggregationExpectations expectations, + DataSet dataSet) { StubMappingScope scope = mainIndex.createScope( incompatibleIndex ); - String fieldPath = mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; + String fieldPath = mainIndex.binding().fieldModels.get( expectations.fieldType() ).relativeFieldName; AggregationScenario scenario = expectations.simple(); @@ -479,26 +507,29 @@ public void multiIndex_withIncompatibleIndex_conversionDisabled() { } private void testValidAggregation(AggregationScenario scenario, StubMappingScope scope, - String fieldPath) { + String fieldPath, DataSet dataSet) { testValidAggregation( scenario, scope, f -> f.matchAll(), - (f, e) -> e.setup( f, fieldPath ) + (f, e) -> e.setup( f, fieldPath ), + dataSet ); } private void testValidAggregationWithConverterSetting(AggregationScenario scenario, - StubMappingScope scope, String fieldPath, ValueConvert convert) { + StubMappingScope scope, String fieldPath, ValueConvert convert, DataSet dataSet) { testValidAggregation( scenario, scope, f -> f.matchAll(), - (f, e) -> e.setupWithConverterSetting( f, fieldPath, convert ) + (f, e) -> e.setupWithConverterSetting( f, fieldPath, convert ), + dataSet ); } private void testValidAggregation(AggregationScenario scenario, StubMappingScope scope, Function predicateContributor, - BiFunction, AggregationFinalStep> aggregationContributor) { + BiFunction, AggregationFinalStep> aggregationContributor, + DataSet dataSet) { AggregationKey aggregationKey = AggregationKey.of( AGGREGATION_NAME ); assertThatQuery( scope.query() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationUnsupportedTypesIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationUnsupportedTypesIT.java index 26b487a80ce..080807528d5 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationUnsupportedTypesIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/SingleFieldAggregationUnsupportedTypesIT.java @@ -23,68 +23,60 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests behavior common to all single-field aggregations (range, terms, ...) * on unsupported types. */ -@RunWith(Parameterized.class) -public class SingleFieldAggregationUnsupportedTypesIT { +class SingleFieldAggregationUnsupportedTypesIT { - private static Set> unsupportedFieldTypes; + private static final Set> unsupportedFieldTypes = new LinkedHashSet<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{1}") - public static Object[][] parameters() { - unsupportedFieldTypes = new LinkedHashSet<>(); - List parameters = new ArrayList<>(); + static { for ( AggregationDescriptor aggregationDescriptor : AggregationDescriptor.getAll() ) { for ( FieldTypeDescriptor fieldTypeDescriptor : FieldTypeDescriptor.getAll() ) { Optional expectations = aggregationDescriptor.getSingleFieldAggregationExpectations( fieldTypeDescriptor ).getUnsupported(); if ( expectations.isPresent() ) { unsupportedFieldTypes.add( fieldTypeDescriptor ); - parameters.add( new Object[] { fieldTypeDescriptor, expectations.get() } ); + parameters.add( Arguments.of( fieldTypeDescriptor, expectations.get() ) ); } } } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldType; - private final UnsupportedSingleFieldAggregationExpectations expectations; - - public SingleFieldAggregationUnsupportedTypesIT(FieldTypeDescriptor fieldType, - UnsupportedSingleFieldAggregationExpectations expectations) { - this.fieldType = fieldType; - this.expectations = expectations; - } - - @Test + @ParameterizedTest(name = "{1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-1748") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.RangeFacetingTest.testRangeQueryWithUnsupportedType") - public void simple() { + void simple(FieldTypeDescriptor fieldType, UnsupportedSingleFieldAggregationExpectations expectations) { SimpleFieldModel model = index.binding().fieldModels.get( fieldType ); String fieldPath = model.relativeFieldName; @@ -103,7 +95,7 @@ public void simple() { } private SimpleFieldModel mapField(IndexSchemaElement parent, String prefix, - Consumer> additionalConfiguration) { + Consumer> additionalConfiguration, FieldTypeDescriptor fieldType) { return SimpleFieldModel.mapper( fieldType, additionalConfiguration ) .map( parent, prefix + fieldType.getUniqueName() ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/TermsAggregationSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/TermsAggregationSpecificsIT.java index f84151456df..6f9ba31180a 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/TermsAggregationSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/aggregation/TermsAggregationSpecificsIT.java @@ -12,7 +12,7 @@ import static org.hibernate.search.util.impl.integrationtest.common.NormalizationUtils.normalize; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatResult; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.Collections; @@ -36,55 +36,54 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests behavior specific to the terms aggregation on supported field types. *

* Behavior common to all single-field aggregations is tested in {@link SingleFieldAggregationBaseIT}. */ -@RunWith(Parameterized.class) -public class TermsAggregationSpecificsIT { +class TermsAggregationSpecificsIT { private static final String AGGREGATION_NAME = "aggregationName"; - private static Set> supportedFieldTypes; - private static List> dataSets; + private static final Set> supportedFieldTypes = new LinkedHashSet<>(); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - supportedFieldTypes = new LinkedHashSet<>(); - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { AggregationDescriptor aggregationDescriptor = TermsAggregationDescriptor.INSTANCE; for ( FieldTypeDescriptor fieldType : FieldTypeDescriptor.getAll() ) { if ( aggregationDescriptor.getSingleFieldAggregationExpectations( fieldType ).isSupported() ) { supportedFieldTypes.add( fieldType ); DataSet dataSet = new DataSet<>( fieldType ); dataSets.add( dataSet ); - parameters.add( new Object[] { fieldType, dataSet } ); + parameters.add( Arguments.of( fieldType, dataSet ) ); } } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); for ( DataSet dataSet : dataSets ) { @@ -92,22 +91,15 @@ public static void setup() { } } - private final FieldTypeDescriptor fieldType; - private final DataSet dataSet; - - public TermsAggregationSpecificsIT(FieldTypeDescriptor fieldType, DataSet dataSet) { - this.fieldType = fieldType; - this.dataSet = dataSet; - } - - @Test - public void superClassFieldType() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void superClassFieldType(FieldTypeDescriptor fieldType, DataSet dataSet) { Class superClass = fieldType.getJavaType().getSuperclass(); - doTestSuperClassFieldType( superClass ); + doTestSuperClassFieldType( superClass, fieldType, dataSet ); } - private void doTestSuperClassFieldType(Class superClass) { + private void doTestSuperClassFieldType(Class superClass, FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -123,15 +115,16 @@ private void doTestSuperClassFieldType(Class superClass) { // All documents should be mentioned in the aggregation, even those excluded by the limit/offset containsInAnyOrder( c -> { dataSet.documentIdPerTerm.forEach( (key, value) -> c.accept( key, (long) value.size() ) ); - } ) + }, fieldType ) ); } /** * Check that defining a predicate will affect the aggregation result. */ - @Test - public void predicate() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void predicate(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -153,15 +146,16 @@ public void predicate() { // Only document 0 should be taken into account by the aggregation containsInAnyOrder( c -> { c.accept( firstTermEntry.getKey(), 2L ); - } ) + }, fieldType ) ); } /** * Check that defining a limit and offset will not affect the aggregation result. */ - @Test - public void limitAndOffset() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void limitAndOffset(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -176,13 +170,14 @@ public void limitAndOffset() { // All documents should be mentioned in the aggregation, even those excluded by the limit/offset containsInAnyOrder( c -> { dataSet.documentIdPerTerm.forEach( (key, value) -> c.accept( key, (long) value.size() ) ); - } ) + }, fieldType ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.SimpleFacetingTest.testDefaultSortOrderIsCount") - public void order_default() { + void order_default(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -200,13 +195,14 @@ public void order_default() { for ( F value : dataSet.valuesInDescendingDocumentCountOrder ) { c.accept( value, (long) dataSet.documentIdPerTerm.get( value ).size() ); } - } ) + }, fieldType ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.SimpleFacetingTest.testCountSortOrderDesc") - public void orderByCountDescending() { + void orderByCountDescending(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -226,13 +222,14 @@ public void orderByCountDescending() { for ( F value : dataSet.valuesInDescendingDocumentCountOrder ) { c.accept( value, (long) dataSet.documentIdPerTerm.get( value ).size() ); } - } ) + }, fieldType ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.SimpleFacetingTest.testCountSortOrderAsc") - public void orderByCountAscending() { + void orderByCountAscending(FieldTypeDescriptor fieldType, DataSet dataSet) { assumeNonDefaultOrdersSupported(); String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; @@ -254,12 +251,13 @@ public void orderByCountAscending() { for ( F value : dataSet.valuesInAscendingDocumentCountOrder ) { c.accept( value, (long) dataSet.documentIdPerTerm.get( value ).size() ); } - } ) + }, fieldType ) ); } - @Test - public void orderByTermDescending() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void orderByTermDescending(FieldTypeDescriptor fieldType, DataSet dataSet) { assumeNonDefaultOrdersSupported(); String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; @@ -281,13 +279,14 @@ public void orderByTermDescending() { for ( F value : dataSet.valuesInDescendingOrder ) { c.accept( value, (long) dataSet.documentIdPerTerm.get( value ).size() ); } - } ) + }, fieldType ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.SimpleFacetingTest.testAlphabeticalSortOrder") - public void orderByTermAscending() { + void orderByTermAscending(FieldTypeDescriptor fieldType, DataSet dataSet) { assumeNonDefaultOrdersSupported(); String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; @@ -309,13 +308,14 @@ public void orderByTermAscending() { for ( F value : dataSet.valuesInAscendingOrder ) { c.accept( value, (long) dataSet.documentIdPerTerm.get( value ).size() ); } - } ) + }, fieldType ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.SimpleFacetingTest.testZeroCountsExcluded") - public void minDocumentCount_positive() { + void minDocumentCount_positive(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -338,13 +338,14 @@ public void minDocumentCount_positive() { c.accept( key, (long) documentCount ); } } ); - } ) + }, fieldType ) ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.SimpleFacetingTest.testZeroCountsIncluded") - public void minDocumentCount_zero() { + void minDocumentCount_zero(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -374,12 +375,13 @@ public void minDocumentCount_zero() { c.accept( e.getKey(), (long) e.getValue().size() ); } ); c.accept( firstTermEntry.getKey(), 0L ); - } ) + }, fieldType ) ); } - @Test - public void minDocumentCount_zero_noMatch() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void minDocumentCount_zero_noMatch(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -403,12 +405,13 @@ public void minDocumentCount_zero_noMatch() { for ( F value : dataSet.valuesInAscendingOrder ) { c.accept( value, 0L ); } - } ) + }, fieldType ) ); } - @Test - public void minDocumentCount_zero_noMatch_orderByTermDescending() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void minDocumentCount_zero_noMatch_orderByTermDescending(FieldTypeDescriptor fieldType, DataSet dataSet) { assumeNonDefaultOrdersSupported(); String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; @@ -435,12 +438,13 @@ public void minDocumentCount_zero_noMatch_orderByTermDescending() { for ( F value : dataSet.valuesInDescendingOrder ) { c.accept( value, 0L ); } - } ) + }, fieldType ) ); } - @Test - public void minDocumentCount_negative() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void minDocumentCount_negative(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; assertThatThrownBy( () -> index.createScope().aggregation().terms().field( fieldPath, fieldType.getJavaType() ) @@ -450,10 +454,11 @@ public void minDocumentCount_negative() { .hasMessageContaining( "must be positive or zero" ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-776") @PortedFromSearch5(original = "org.hibernate.search.test.query.facet.SimpleFacetingTest.testMaxFacetCounts") - public void maxTermCount_positive() { + void maxTermCount_positive(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -475,7 +480,7 @@ public void maxTermCount_positive() { F valueWithMostDocuments = dataSet.valuesInDescendingDocumentCountOrder.get( 0 ); c.accept( valueWithMostDocuments, (long) dataSet.documentIdPerTerm.get( valueWithMostDocuments ).size() ); - } ) + }, fieldType ) ); } @@ -483,8 +488,9 @@ public void maxTermCount_positive() { * Test maxTermCount with a non-default sort by ascending term value. * The returned terms should be the "lowest" dataSet.values. */ - @Test - public void maxTermCount_positive_orderByTermAscending() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void maxTermCount_positive_orderByTermAscending(FieldTypeDescriptor fieldType, DataSet dataSet) { assumeNonDefaultOrdersSupported(); String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; @@ -508,12 +514,13 @@ public void maxTermCount_positive_orderByTermAscending() { containsInAnyOrder( c -> { F lowestValue = dataSet.valuesInAscendingOrder.get( 0 ); c.accept( lowestValue, (long) dataSet.documentIdPerTerm.get( lowestValue ).size() ); - } ) + }, fieldType ) ); } - @Test - public void maxTermCount_positive_orderByCountAscending() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void maxTermCount_positive_orderByCountAscending(FieldTypeDescriptor fieldType, DataSet dataSet) { assumeNonDefaultOrdersSupported(); String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; @@ -538,12 +545,13 @@ public void maxTermCount_positive_orderByCountAscending() { F valueWithLeastDocuments = dataSet.valuesInAscendingDocumentCountOrder.get( 0 ); c.accept( valueWithLeastDocuments, (long) dataSet.documentIdPerTerm.get( valueWithLeastDocuments ).size() ); - } ) + }, fieldType ) ); } - @Test - public void maxTermCount_zero() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void maxTermCount_zero(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; assertThatThrownBy( () -> index.createScope().aggregation().terms().field( fieldPath, fieldType.getJavaType() ) @@ -553,8 +561,9 @@ public void maxTermCount_zero() { .hasMessageContaining( "must be strictly positive" ); } - @Test - public void maxTermCount_negative() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void maxTermCount_negative(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; assertThatThrownBy( () -> index.createScope().aggregation().terms().field( fieldPath, fieldType.getJavaType() ) @@ -564,9 +573,10 @@ public void maxTermCount_negative() { .hasMessageContaining( "must be strictly positive" ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4544") - public void maxTermCount_integerMaxValue() { + void maxTermCount_integerMaxValue(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -582,16 +592,17 @@ public void maxTermCount_integerMaxValue() { for ( F value : dataSet.valuesInDescendingOrder ) { c.accept( value, (long) dataSet.documentIdPerTerm.get( value ).size() ); } - } ) + }, fieldType ) ); } // This is interesting even if we already test Integer.MAX_VALUE (see above), // because Lucene has some hardcoded limits for PriorityQueue sizes, // somewhere around 2147483631, which is lower than Integer.MAX_VALUE. - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4544") - public void maxTermCount_veryLarge() { + void maxTermCount_veryLarge(FieldTypeDescriptor fieldType, DataSet dataSet) { String fieldPath = index.binding().fieldModels.get( fieldType ).relativeFieldName; AggregationKey> aggregationKey = AggregationKey.of( AGGREGATION_NAME ); @@ -607,7 +618,7 @@ public void maxTermCount_veryLarge() { for ( F value : dataSet.valuesInDescendingOrder ) { c.accept( value, (long) dataSet.documentIdPerTerm.get( value ).size() ); } - } ) + }, fieldType ) ); } @@ -617,13 +628,14 @@ public void maxTermCount_veryLarge() { private void assumeNonDefaultOrdersSupported() { assumeTrue( - "Non-default orders are not supported for terms aggregations with this backend", - TckConfiguration.get().getBackendFeatures().nonDefaultOrderInTermsAggregations() + TckConfiguration.get().getBackendFeatures().nonDefaultOrderInTermsAggregations(), + "Non-default orders are not supported for terms aggregations with this backend" ); } @SuppressWarnings("unchecked") - private Consumer> containsExactly(Consumer> expectationBuilder) { + private Consumer> containsExactly(Consumer> expectationBuilder, + FieldTypeDescriptor fieldType) { List> expected = new ArrayList<>(); expectationBuilder.accept( (k, v) -> expected.add( entry( fieldType.toExpectedDocValue( k ), v ) ) ); return actual -> assertThat( normalize( actual ) ) @@ -631,7 +643,8 @@ private Consumer> containsExactly(Consumer> ex } @SuppressWarnings("unchecked") - private Consumer> containsInAnyOrder(Consumer> expectationBuilder) { + private Consumer> containsInAnyOrder(Consumer> expectationBuilder, + FieldTypeDescriptor fieldType) { List> expected = new ArrayList<>(); expectationBuilder.accept( (k, v) -> expected.add( entry( fieldType.toExpectedDocValue( k ), v ) ) ); return actual -> assertThat( normalize( actual ).entrySet() ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/bool/BooleanSortAndRangePredicateIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/bool/BooleanSortAndRangePredicateIT.java index ae8079a6aa3..217b88cca3d 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/bool/BooleanSortAndRangePredicateIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/bool/BooleanSortAndRangePredicateIT.java @@ -6,8 +6,7 @@ */ package org.hibernate.search.integrationtest.backend.tck.search.bool; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import java.util.function.Function; @@ -21,24 +20,22 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.search.sort.dsl.SearchSortFactory; import org.hibernate.search.engine.search.sort.dsl.SortFinalStep; -import org.hibernate.search.integrationtest.backend.tck.search.predicate.RangePredicateSpecificsIT; -import org.hibernate.search.integrationtest.backend.tck.search.sort.FieldSortBaseIT; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests sorting and ranging behaviour querying a boolean type field - * - * @see FieldSortBaseIT - * @see RangePredicateSpecificsIT + *

+ * See {@code org.hibernate.search.integrationtest.backend.tck.search.sort.FieldSortBaseIT} + * {@code org.hibernate.search.integrationtest.backend.tck.search.predicate.RangePredicateSpecificsIT} */ -public class BooleanSortAndRangePredicateIT { +class BooleanSortAndRangePredicateIT { public static final String FIELD_PATH = "boolean"; @@ -48,13 +45,13 @@ public class BooleanSortAndRangePredicateIT { public static final String DOCUMENT_4 = "4"; public static final String DOCUMENT_5 = "5"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); @@ -77,7 +74,7 @@ private SearchQuery rangeQuery(Function query = sortQuery( c -> c.field( FIELD_PATH ).missing().last() ); assertHasHitsWithBooleanProperties( query, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, null ); @@ -96,26 +93,26 @@ public void sortByFieldQuery() { } @Test - public void rangePredicateAtLeast() { + void rangePredicateAtLeast() { SearchQuery query = rangeQuery( f -> f.range().field( FIELD_PATH ).atLeast( Boolean.TRUE ) ); assertHasHitsWithBooleanProperties( query, Boolean.TRUE, Boolean.TRUE ); } @Test - public void rangePredicateAtMost() { + void rangePredicateAtMost() { SearchQuery query = rangeQuery( f -> f.range().field( FIELD_PATH ).atMost( Boolean.FALSE ) ); assertHasHitsWithBooleanProperties( query, Boolean.FALSE, Boolean.FALSE ); } @Test - public void rangePredicateBetween() { + void rangePredicateBetween() { SearchQuery query = rangeQuery( f -> f.range().field( FIELD_PATH ) .between( Boolean.FALSE, Boolean.FALSE ) ); assertHasHitsWithBooleanProperties( query, Boolean.FALSE, Boolean.FALSE ); } @Test - public void rangeBetweenAndSortByField() { + void rangeBetweenAndSortByField() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() .where( f -> f.range().field( FIELD_PATH ).between( Boolean.FALSE, Boolean.TRUE ) ) @@ -127,19 +124,19 @@ public void rangeBetweenAndSortByField() { private void assertHasHitsWithBooleanProperties(SearchQuery query, Boolean... expectedPropertyValues) { List hits = query.fetchAll().hits(); - assertEquals( expectedPropertyValues.length, hits.size() ); + assertThat( hits ).hasSize( expectedPropertyValues.length ); for ( int i = 0; i < expectedPropertyValues.length; i++ ) { Boolean expectedPropertyValue = expectedPropertyValues[i]; if ( expectedPropertyValue == Boolean.TRUE ) { - assertTrue( isTrueDocument( hits.get( i ) ) ); + assertThat( isTrueDocument( hits.get( i ) ) ).isTrue(); } else if ( expectedPropertyValue == Boolean.FALSE ) { - assertTrue( isFalseDocument( hits.get( i ) ) ); + assertThat( isFalseDocument( hits.get( i ) ) ).isTrue(); } else { - assertTrue( isNullDocument( hits.get( i ) ) ); + assertThat( isNullDocument( hits.get( i ) ) ).isTrue(); } } } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/AbstractHighlighterIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/AbstractHighlighterIT.java index 6a03327c892..89a87fdd6ad 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/AbstractHighlighterIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/AbstractHighlighterIT.java @@ -6,10 +6,10 @@ */ package org.hibernate.search.integrationtest.backend.tck.search.highlight; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchHitsAssert.assertThatHits; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.time.LocalDate; import java.util.Arrays; @@ -31,25 +31,24 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; -public abstract class AbstractHighlighterIT { +abstract class AbstractHighlighterIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @Rule + @RegisterExtension public final ExpectedLog4jLog logged = ExpectedLog4jLog.create(); protected static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); @@ -61,8 +60,8 @@ public abstract class AbstractHighlighterIT { protected static final SimpleMappedIndex nestedIndex = SimpleMappedIndex.of( NestedIndexBinding::new ) .name( "nestedIndex" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ) .withIndex( matchingIndex ) .withIndex( notMatchingTypeIndex ) @@ -129,7 +128,7 @@ public static void setup() { abstract HighlighterOptionsStep highlighter(SearchHighlighterFactory factory); @Test - public void highlighterNoConfigurationAtAll() { + void highlighterNoConfigurationAtAll() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -146,7 +145,7 @@ public void highlighterNoConfigurationAtAll() { } @Test - public void highlighterNoSettings() { + void highlighterNoSettings() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -164,7 +163,7 @@ public void highlighterNoSettings() { } @Test - public void highlighterNoSettingsMultipleOccurrencesWithinSameLine() { + void highlighterNoSettingsMultipleOccurrencesWithinSameLine() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -181,7 +180,7 @@ public void highlighterNoSettingsMultipleOccurrencesWithinSameLine() { } @Test - public void customTagGlobal() { + void customTagGlobal() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -199,7 +198,7 @@ public void customTagGlobal() { } @Test - public void customTagField() { + void customTagField() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -217,7 +216,7 @@ public void customTagField() { } @Test - public void customTagOverride() { + void customTagOverride() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -236,7 +235,7 @@ public void customTagOverride() { } @Test - public void lastTagWins() { + void lastTagWins() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -258,7 +257,7 @@ public void lastTagWins() { } @Test - public void encoderGlobalHtml() { + void encoderGlobalHtml() { encoderGlobal( HighlighterEncoder.HTML, "<body><h1>This is a Heading</h1><p>This is a paragraph</p></body>" @@ -266,7 +265,7 @@ public void encoderGlobalHtml() { } @Test - public void encoderGlobalDefault() { + void encoderGlobalDefault() { encoderGlobal( HighlighterEncoder.DEFAULT, "

This is a Heading

This is a paragraph

" @@ -290,7 +289,7 @@ protected void encoderGlobal(HighlighterEncoder encoder, String result) { } @Test - public void encoderFieldHtml() { + void encoderFieldHtml() { encoderField( HighlighterEncoder.HTML, "<body><h1>This is a Heading</h1><p>This is a paragraph</p></body>" @@ -298,17 +297,17 @@ public void encoderFieldHtml() { } @Test - public void encoderFieldDefault() { + void encoderFieldDefault() { encoderField( HighlighterEncoder.DEFAULT, "

This is a Heading

This is a paragraph

" ); } - public void encoderField(HighlighterEncoder encoder, String result) { + void encoderField(HighlighterEncoder encoder, String result) { assumeTrue( - "This test only make sense for backends that support encoder override at field level.", - TckConfiguration.get().getBackendFeatures().supportsHighlighterEncoderAtFieldLevel() + TckConfiguration.get().getBackendFeatures().supportsHighlighterEncoderAtFieldLevel(), + "This test only make sense for backends that support encoder override at field level." ); StubMappingScope scope = index.createScope(); @@ -326,7 +325,7 @@ public void encoderField(HighlighterEncoder encoder, String result) { } @Test - public void encoderOverrideHtml() { + void encoderOverrideHtml() { encoderOverride( HighlighterEncoder.DEFAULT, HighlighterEncoder.HTML, @@ -335,7 +334,7 @@ public void encoderOverrideHtml() { } @Test - public void encoderOverrideDefault() { + void encoderOverrideDefault() { encoderOverride( HighlighterEncoder.HTML, HighlighterEncoder.DEFAULT, @@ -343,10 +342,10 @@ public void encoderOverrideDefault() { ); } - public void encoderOverride(HighlighterEncoder globalEncoder, HighlighterEncoder encoder, String result) { + void encoderOverride(HighlighterEncoder globalEncoder, HighlighterEncoder encoder, String result) { assumeTrue( - "This test only make sense for backends that support encoder override at field level.", - TckConfiguration.get().getBackendFeatures().supportsHighlighterEncoderAtFieldLevel() + TckConfiguration.get().getBackendFeatures().supportsHighlighterEncoderAtFieldLevel(), + "This test only make sense for backends that support encoder override at field level." ); StubMappingScope scope = index.createScope(); @@ -365,7 +364,7 @@ public void encoderOverride(HighlighterEncoder globalEncoder, HighlighterEncoder } @Test - public void fragmentSize() { + void fragmentSize() { assumeTrue( supportsFragmentSize() ); StubMappingScope scope = index.createScope(); @@ -383,7 +382,7 @@ public void fragmentSize() { } @Test - public void fragmentSizeNotSupported() { + void fragmentSizeNotSupported() { assumeFalse( supportsFragmentSize() ); assertThatThrownBy( @@ -407,7 +406,7 @@ protected boolean supportsFragmentSize() { protected abstract List fragmentSizeResult(); @Test - public void numberOfFragments() { + void numberOfFragments() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -430,7 +429,7 @@ protected List numberOfFragmentsResult() { } @Test - public void defaultNoMatchSize() { + void defaultNoMatchSize() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -448,7 +447,7 @@ public void defaultNoMatchSize() { } @Test - public void noMatchSize() { + void noMatchSize() { assumeTrue( supportsNoMatchSize() ); StubMappingScope scope = index.createScope(); @@ -466,7 +465,7 @@ public void noMatchSize() { } @Test - public void noMatchSizeNotSupported() { + void noMatchSizeNotSupported() { assumeFalse( supportsNoMatchSize() ); StubMappingScope scope = index.createScope(); @@ -489,7 +488,7 @@ protected boolean supportsNoMatchSize() { } @Test - public void noMatchSizeMultiField() { + void noMatchSizeMultiField() { assumeTrue( supportsNoMatchSizeOnMultivaluedFields() ); StubMappingScope scope = index.createScope(); @@ -514,7 +513,7 @@ protected boolean supportsNoMatchSizeOnMultivaluedFields() { } @Test - public void compositeHighlight() { + void compositeHighlight() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -550,7 +549,7 @@ public void compositeHighlight() { } @Test - public void compositeHighlightMultipleConfigurations() { + void compositeHighlightMultipleConfigurations() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -588,7 +587,7 @@ public void compositeHighlightMultipleConfigurations() { } @Test - public void multivaluedField() { + void multivaluedField() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -603,7 +602,7 @@ public void multivaluedField() { } @Test - public void multivaluedFieldDuplicated() { + void multivaluedFieldDuplicated() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -635,7 +634,7 @@ protected List multivaluedFieldResult() { } @Test - public void nestedField() { + void nestedField() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -654,7 +653,7 @@ public void nestedField() { } @Test - public void nestedFieldWildcard() { + void nestedFieldWildcard() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -673,7 +672,7 @@ public void nestedFieldWildcard() { } @Test - public void simpleFieldWildcard() { + void simpleFieldWildcard() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -692,10 +691,10 @@ public void simpleFieldWildcard() { } @Test - public void orderByScore() { + void orderByScore() { assumeTrue( - "Some versions of the backend have a bug that prevents them from correctly sorting the results.", - supportsOrderByScoreMultivaluedField() + supportsOrderByScoreMultivaluedField(), + "Some versions of the backend have a bug that prevents them from correctly sorting the results." ); StubMappingScope scope = index.createScope(); @@ -727,7 +726,7 @@ protected boolean supportsOrderByScoreMultivaluedField() { } @Test - public void unknownNamedHighlighter() { + void unknownNamedHighlighter() { assertThatThrownBy( () -> index.createScope().query().select( f -> f.highlight( "string" ).highlighter( "not-configured-highlighter" ) @@ -744,7 +743,7 @@ public void unknownNamedHighlighter() { } @Test - public void highlightNonAnalyzedField() { + void highlightNonAnalyzedField() { assertThatThrownBy( () -> index.createScope().query().select( f -> f.highlight( "notAnalyzedString" ) @@ -759,7 +758,7 @@ public void highlightNonAnalyzedField() { } @Test - public void multipleIndexesScopeIncompatibleTypes() { + void multipleIndexesScopeIncompatibleTypes() { assertThatThrownBy( () -> index.createScope( notMatchingTypeIndex ).query().select( f -> f.highlight( "string" ) @@ -774,7 +773,7 @@ public void multipleIndexesScopeIncompatibleTypes() { } @Test - public void multipleIndexesScopeIncompatibleTypesNested() { + void multipleIndexesScopeIncompatibleTypesNested() { assertThatThrownBy( () -> index.createScope( notMatchingTypeIndex ).query().select( f -> f.highlight( "nested.nestedString" ) @@ -789,7 +788,7 @@ public void multipleIndexesScopeIncompatibleTypesNested() { } @Test - public void multipleIndexesScopeCompatibleTypes() { + void multipleIndexesScopeCompatibleTypes() { SearchQuery> highlights = index.createScope( matchingIndex ).query().select( f -> f.highlight( "string" ) ).where( f -> f.match().field( "string" ).matching( "dog" ) ) @@ -805,7 +804,7 @@ public void multipleIndexesScopeCompatibleTypes() { } @Test - public void prebuiltHighlighter() { + void prebuiltHighlighter() { SearchHighlighter highlighter = highlighter( index.createScope().highlighter() ).tag( "---", "---" ) .toHighlighter(); @@ -825,7 +824,7 @@ public void prebuiltHighlighter() { } @Test - public void prebuiltNamedHighlighter() { + void prebuiltNamedHighlighter() { SearchHighlighter highlighter = highlighter( index.createScope().highlighter() ).tag( "---", "---" ) .toHighlighter(); @@ -845,7 +844,7 @@ public void prebuiltNamedHighlighter() { } @Test - public void prebuiltHighlighterWrongScope() { + void prebuiltHighlighterWrongScope() { SearchHighlighter highlighter = highlighter( notMatchingTypeIndex.createScope().highlighter() ).tag( "---", "---" ) .toHighlighter(); @@ -862,7 +861,7 @@ public void prebuiltHighlighterWrongScope() { } @Test - public void highlightInNestedContextNotAllowed() { + void highlightInNestedContextNotAllowed() { List objects = Arrays.asList( "objectDefault", "objectFlattened" ); for ( String object : objects ) { for ( String level2 : objects ) { @@ -892,7 +891,7 @@ public void highlightInNestedContextNotAllowed() { } @Test - public void phraseMatching() { + void phraseMatching() { SearchQuery> highlights = index.createScope().query().select( f -> f.highlight( "multiValuedString" ) ).where( f -> f.phrase().field( "multiValuedString" ).matching( "brown fox" ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightProjectionTypeIndependentIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightProjectionTypeIndependentIT.java index 819390e1777..e34e20d41b6 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightProjectionTypeIndependentIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightProjectionTypeIndependentIT.java @@ -18,33 +18,31 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.TermVector; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -import org.assertj.core.api.AssertionsForClassTypes; +class HighlightProjectionTypeIndependentIT { -public class HighlightProjectionTypeIndependentIT { - - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private static final SimpleMappedIndex nestedIndex = SimpleMappedIndex.of( NestedIndexBinding::new ).name( "nestedIndex" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).withIndex( nestedIndex ).setup(); } @Test - public void unknownField() { + void unknownField() { StubMappingScope scope = index.createScope(); assertThatThrownBy( @@ -59,7 +57,7 @@ public void unknownField() { } @Test - public void objectField_nested() { + void objectField_nested() { String fieldPath = index.binding().nestedObject.relativeFieldName; StubMappingScope scope = index.createScope(); @@ -70,7 +68,7 @@ public void objectField_nested() { } @Test - public void objectField_flattened() { + void objectField_flattened() { String fieldPath = index.binding().flattenedObject.relativeFieldName; StubMappingScope scope = index.createScope(); @@ -81,8 +79,8 @@ public void objectField_flattened() { } @Test - public void highlighterNullName() { - AssertionsForClassTypes.assertThatThrownBy( + void highlighterNullName() { + assertThatThrownBy( () -> index.createScope().query().select( f -> f.highlight( "string1" ) ).where( f -> f.matchAll() ) @@ -95,8 +93,8 @@ public void highlighterNullName() { } @Test - public void highlighterEmptyName() { - AssertionsForClassTypes.assertThatThrownBy( + void highlighterEmptyName() { + assertThatThrownBy( () -> index.createScope().query().select( f -> f.highlight( "string1" ) ).where( f -> f.matchAll() ) @@ -109,8 +107,8 @@ public void highlighterEmptyName() { } @Test - public void highlighterSameName() { - AssertionsForClassTypes.assertThatThrownBy( + void highlighterSameName() { + assertThatThrownBy( () -> index.createScope().query().select( f -> f.highlight( "string1" ) ).where( f -> f.matchAll() ) @@ -124,8 +122,8 @@ public void highlighterSameName() { } @Test - public void cannotHighlightNestedObjectStructureFields() { - AssertionsForClassTypes.assertThatThrownBy( () -> nestedIndex.createScope().query().select( + void cannotHighlightNestedObjectStructureFields() { + assertThatThrownBy( () -> nestedIndex.createScope().query().select( f -> f.highlight( "nested.nestedString" ) ).where( f -> f.matchAll() ) .toQuery() ).isInstanceOf( SearchException.class ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightProjectionUnsupportedTypesIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightProjectionUnsupportedTypesIT.java index 9a9a8e447c9..6e3cc0ce1f0 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightProjectionUnsupportedTypesIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightProjectionUnsupportedTypesIT.java @@ -19,58 +19,50 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.AnalyzedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests basic behavior of highlight projections common to all unsupported types, * i.e. error messages. */ -@RunWith(Parameterized.class) -public class HighlightProjectionUnsupportedTypesIT { +class HighlightProjectionUnsupportedTypesIT { private static Stream> unsupportedTypeDescriptors() { return FieldTypeDescriptor.getAll().stream() .filter( typeDescriptor -> !AnalyzedStringFieldTypeDescriptor.INSTANCE.equals( typeDescriptor ) ); } - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - List parameters = new ArrayList<>(); - unsupportedTypeDescriptors().forEach( fieldTypeDescriptor -> { - parameters.add( new Object[] { fieldTypeDescriptor } ); - } ); - return parameters.toArray( new Object[0][] ); + public static List params() { + List parameters = new ArrayList<>(); + unsupportedTypeDescriptors().forEach( fieldTypeDescriptor -> parameters.add( Arguments.of( fieldTypeDescriptor ) ) ); + return parameters; } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldTypeDescriptor; - public HighlightProjectionUnsupportedTypesIT(FieldTypeDescriptor fieldTypeDescriptor) { - this.fieldTypeDescriptor = fieldTypeDescriptor; - } - - @Test - public void notSupported() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void notSupported(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = index.createScope(); - String absoluteFieldPath = getFieldPath(); + String absoluteFieldPath = getFieldPath( fieldTypeDescriptor ); assertThatThrownBy( () -> scope.query().select( f -> f.highlight( absoluteFieldPath ) ).where( f -> f.matchAll() ).toQuery() @@ -82,7 +74,7 @@ public void notSupported() { ); } - private String getFieldPath() { + private String getFieldPath(FieldTypeDescriptor fieldTypeDescriptor) { return index.binding().fieldModels.get( fieldTypeDescriptor ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightableCombinationsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightableCombinationsIT.java index 60b99fea2c6..ff2691159c6 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightableCombinationsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlightableCombinationsIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.backend.tck.search.highlight; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.Arrays; import java.util.Collections; @@ -15,20 +15,20 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.types.Highlightable; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class HighlightableCombinationsIT { +class HighlightableCombinationsIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); @Test - public void noWithOtherOptions() { + void noWithOtherOptions() { class IndexNoPlainBinding { final IndexFieldReference stringField; @@ -70,7 +70,7 @@ class IndexNoUnifiedFastVectorBinding { } @Test - public void empty() { + void empty() { class IndexBinding { final IndexFieldReference stringField; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterFastVectorIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterFastVectorIT.java index 8ebf4f6a698..21fb613d76b 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterFastVectorIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterFastVectorIT.java @@ -20,9 +20,9 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class HighlighterFastVectorIT extends AbstractHighlighterIT { +class HighlighterFastVectorIT extends AbstractHighlighterIT { @Override HighlighterFastVectorHighlighterOptionsStep highlighter(SearchHighlighterFactory factory) { @@ -66,7 +66,7 @@ protected boolean supportsNoMatchSizeOnMultivaluedFields() { } @Test - public void boundaryScannerCharsExplicit() { + void boundaryScannerCharsExplicit() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -89,7 +89,7 @@ public void boundaryScannerCharsExplicit() { } @Test - public void boundaryScannerWord() { + void boundaryScannerWord() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -114,7 +114,7 @@ public void boundaryScannerWord() { } @Test - public void boundaryScannerWordUsingLambda() { + void boundaryScannerWordUsingLambda() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -136,7 +136,7 @@ public void boundaryScannerWordUsingLambda() { } @Test - public void boundaryScannerSentence() { + void boundaryScannerSentence() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -170,7 +170,7 @@ public void boundaryScannerSentence() { } @Test - public void styledSchema() { + void styledSchema() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -192,7 +192,7 @@ public void styledSchema() { * predefined styled schema. */ @Test - public void styledSchemaWinsOverTags() { + void styledSchemaWinsOverTags() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -210,7 +210,7 @@ public void styledSchemaWinsOverTags() { } @Test - public void tagsWinOverStyledSchema() { + void tagsWinOverStyledSchema() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -228,7 +228,7 @@ public void tagsWinOverStyledSchema() { } @Test - public void boundaryCharacters() { + void boundaryCharacters() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -277,7 +277,7 @@ public void boundaryCharacters() { } @Test - public void boundaryCharactersAsArray() { + void boundaryCharactersAsArray() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -302,7 +302,7 @@ public void boundaryCharactersAsArray() { } @Test - public void phraseLimit() { + void phraseLimit() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -322,7 +322,7 @@ public void phraseLimit() { } @Test - public void multipleDifferentTags() { + void multipleDifferentTags() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -345,7 +345,7 @@ public void multipleDifferentTags() { } @Test - public void multipleStyledTags() { + void multipleStyledTags() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterPlainIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterPlainIT.java index 5e464fd9a36..aee95197e5e 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterPlainIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterPlainIT.java @@ -18,9 +18,9 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class HighlighterPlainIT extends AbstractHighlighterIT { +class HighlighterPlainIT extends AbstractHighlighterIT { @Override HighlighterPlainOptionsStep highlighter(SearchHighlighterFactory factory) { @@ -50,7 +50,7 @@ protected boolean supportsPhraseMatching() { } @Test - public void plainFragmenterSimple() { + void plainFragmenterSimple() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -70,7 +70,7 @@ public void plainFragmenterSimple() { } @Test - public void plainFragmenterSpan() { + void plainFragmenterSpan() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterUnifiedIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterUnifiedIT.java index 2a7b71b7606..be2a09b3a82 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterUnifiedIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/HighlighterUnifiedIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.backend.tck.search.highlight; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchHitsAssert.assertThatHits; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Arrays; import java.util.List; @@ -19,9 +19,9 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class HighlighterUnifiedIT extends AbstractHighlighterIT { +class HighlighterUnifiedIT extends AbstractHighlighterIT { @Override HighlighterUnifiedOptionsStep highlighter(SearchHighlighterFactory factory) { @@ -49,7 +49,7 @@ protected boolean supportsPhraseMatching() { } @Test - public void boundaryScannerWord() { + void boundaryScannerWord() { StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( @@ -70,10 +70,9 @@ public void boundaryScannerWord() { } @Test - public void boundaryScannerSentenceExplicit() { + void boundaryScannerSentenceExplicit() { assumeTrue( - TckConfiguration.get().getBackendFeatures().supportsHighlighterUnifiedTypeFragmentSize() - ); + TckConfiguration.get().getBackendFeatures().supportsHighlighterUnifiedTypeFragmentSize() ); StubMappingScope scope = index.createScope(); SearchQuery> highlights = scope.query().select( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/IncompatibleCombinationHighlighterIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/IncompatibleCombinationHighlighterIT.java index 134b78e582e..037c7992829 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/IncompatibleCombinationHighlighterIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/highlight/IncompatibleCombinationHighlighterIT.java @@ -15,20 +15,20 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.types.Highlightable; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IncompatibleCombinationHighlighterIT { +class IncompatibleCombinationHighlighterIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.create(); @Test - public void incompatibleHighlightableConfiguration() { + void incompatibleHighlightableConfiguration() { class IncompatibleTypeIndexBinding { final IndexFieldReference stringField; @@ -52,7 +52,7 @@ class IncompatibleTypeIndexBinding { } @Test - public void incompatibleHighlighter() { + void incompatibleHighlighter() { class IncompatibleTypeIndexBinding { final IndexFieldReference stringField; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateArgumentCheckingIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateArgumentCheckingIT.java index 12d75626e3b..e87423368b2 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateArgumentCheckingIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateArgumentCheckingIT.java @@ -16,31 +16,24 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateArgumentCheckingIT { - private final SimpleMappedIndex index; - private final FieldTypeDescriptor fieldType; - - protected AbstractPredicateArgumentCheckingIT(SimpleMappedIndex index, - FieldTypeDescriptor fieldType) { - this.index = index; - this.fieldType = fieldType; - } - - @Test - public void nullMatchingParam() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void nullMatchingParam(SimpleMappedIndex index, FieldTypeDescriptor fieldType) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> tryPredicateWithNullMatchingParam( f, fieldPath() ) ) + assertThatThrownBy( () -> tryPredicateWithNullMatchingParam( f, fieldPath( index, fieldType ) ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContainingAll( "must not be null" ); } protected abstract void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, String fieldPath); - protected String fieldPath() { + protected String fieldPath(SimpleMappedIndex index, FieldTypeDescriptor fieldType) { return index.binding().field.get( fieldType ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateConfigurableAnalysisIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateConfigurableAnalysisIT.java index 116122c683b..f652f3f13cd 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateConfigurableAnalysisIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateConfigurableAnalysisIT.java @@ -17,7 +17,7 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class AbstractPredicateConfigurableAnalysisIT extends AbstractPredicateSimpleAnalysisIT { @@ -29,7 +29,7 @@ protected AbstractPredicateConfigurableAnalysisIT(SimpleMappedIndex index.query() @@ -80,7 +80,7 @@ public void analyzerOverride_withNormalizer() { } @Test - public void analyzerOverride_notExistingName() { + void analyzerOverride_notExistingName() { String whitespaceAnalyzedField = index.binding().whitespaceAnalyzedField.relativeFieldName; assertThatThrownBy( () -> index.query() @@ -93,7 +93,7 @@ public void analyzerOverride_notExistingName() { } @Test - public void skipAnalysis() { + void skipAnalysis() { String absoluteFieldPath = index.binding().whitespaceLowercaseAnalyzedField.relativeFieldName; assertThatQuery( index.query() @@ -115,7 +115,7 @@ public void skipAnalysis() { } @Test - public void analyzerOverride_normalizedStringField() { + void analyzerOverride_normalizedStringField() { String absoluteFieldPath = index.binding().normalizedStringField.relativeFieldName; assertThatQuery( index.query() @@ -128,7 +128,7 @@ public void analyzerOverride_normalizedStringField() { @Test @TestForIssue(jiraKey = { "HSEARCH-2534", "HSEARCH-3042" }) - public void analyzerOverride_queryOnlyAnalyzer() { + void analyzerOverride_queryOnlyAnalyzer() { String absoluteFieldPath = index.binding().whitespaceLowercaseAnalyzedField.relativeFieldName; String ngramFieldPath = index.binding().ngramSearchAnalyzedField.relativeFieldName; @@ -154,7 +154,7 @@ public void analyzerOverride_queryOnlyAnalyzer() { } @Test - public void multiIndex_incompatibleAnalyzer_overrideAnalyzer() { + void multiIndex_incompatibleAnalyzer_overrideAnalyzer() { StubMappingScope scope = index.createScope( incompatibleSearchAnalyzerIndex ); String absoluteFieldPath = index.binding().analyzedStringField.relativeFieldName; @@ -168,7 +168,7 @@ public void multiIndex_incompatibleAnalyzer_overrideAnalyzer() { } @Test - public void multiIndex_incompatibleAnalyzer_skipAnalysis() { + void multiIndex_incompatibleAnalyzer_skipAnalysis() { StubMappingScope scope = index.createScope( incompatibleSearchAnalyzerIndex ); String absoluteFieldPath = index.binding().analyzedStringField.relativeFieldName; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateFieldInObjectFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateFieldInObjectFieldIT.java index 589620f2d6f..39807cbefce 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateFieldInObjectFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateFieldInObjectFieldIT.java @@ -15,76 +15,89 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateFieldInObjectFieldIT> extends AbstractPredicateInObjectFieldIT { - protected final DataSet dataSet; - - public AbstractPredicateFieldInObjectFieldIT(SimpleMappedIndex mainIndex, - SimpleMappedIndex missingFieldIndex, DataSet dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); - this.dataSet = dataSet; - } - - @Test + @ParameterizedTest(name = "{2}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void factoryWithRoot_nested() { + void factoryWithRoot_nested(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, DataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> predicateWithRelativePath( f.withRoot( binding.nested.absolutePath ), binding.nested, 0 ) ) + .where( f -> predicateWithRelativePath( f.withRoot( mainIndex.binding().nested.absolutePath ), + mainIndex.binding().nested, 0, + dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test + @ParameterizedTest(name = "{2}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void factoryWithRoot_flattened() { + void factoryWithRoot_flattened(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, DataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> predicateWithRelativePath( f.withRoot( binding.flattened.absolutePath ), binding.flattened, 0 ) ) + .where( f -> predicateWithRelativePath( f.withRoot( mainIndex.binding().flattened.absolutePath ), + mainIndex.binding().flattened, 0, + dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test + @ParameterizedTest(name = "{2}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void inNamedPredicate_nested() { + void inNamedPredicate_nested(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, DataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> f.named( binding.nested.absolutePath + "." + StubPredicateDefinition.NAME ) + .where( f -> f.named( mainIndex.binding().nested.absolutePath + "." + StubPredicateDefinition.NAME ) .param( StubPredicateDefinition.IMPL_PARAM_NAME, - (PredicateDefinition) context -> predicateWithRelativePath( context.predicate(), binding.nested, - 0 ) + (PredicateDefinition) context -> predicateWithRelativePath( context.predicate(), + mainIndex.binding().nested, 0, dataSet ) .toPredicate() ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test + @ParameterizedTest(name = "{2}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void inNamedPredicate_flattened() { + void inNamedPredicate_flattened(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, DataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> f.named( binding.flattened.absolutePath + "." + StubPredicateDefinition.NAME ) + .where( f -> f.named( mainIndex.binding().flattened.absolutePath + "." + StubPredicateDefinition.NAME ) .param( StubPredicateDefinition.IMPL_PARAM_NAME, (PredicateDefinition) context -> predicateWithRelativePath( context.predicate(), - binding.flattened, 0 ) + mainIndex.binding().flattened, 0, + dataSet + ) .toPredicate() ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } @Override + @SuppressWarnings("unchecked") protected final PredicateFinalStep predicate(SearchPredicateFactory f, ObjectFieldBinding objectFieldBinding, - int matchingDocOrdinal) { - return predicate( f, objectFieldBinding.absoluteFieldPath( dataSet.fieldType ), matchingDocOrdinal ); + int matchingDocOrdinal, AbstractPredicateDataSet dataSet) { + return predicate( f, objectFieldBinding.absoluteFieldPath( ( (DataSet) dataSet ).fieldType ), matchingDocOrdinal, + (DataSet) dataSet + ); } protected final PredicateFinalStep predicateWithRelativePath(SearchPredicateFactory f, ObjectFieldBinding objectFieldBinding, - int matchingDocOrdinal) { - return predicate( f, objectFieldBinding.relativeFieldPath( dataSet.fieldType ), matchingDocOrdinal ); + int matchingDocOrdinal, DataSet dataSet) { + return predicate( f, objectFieldBinding.relativeFieldPath( dataSet.fieldType ), matchingDocOrdinal, dataSet ); } - protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal); + protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet); public static final class DataSet> extends AbstractPerFieldTypePredicateDataSet { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateFieldScoreIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateFieldScoreIT.java index 24d5a452f56..e3dd387d3f4 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateFieldScoreIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateFieldScoreIT.java @@ -20,147 +20,189 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; +import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateFieldScoreIT> extends AbstractPredicateScoreIT { - private final SimpleMappedIndex index; - protected final DataSet dataSet; - - public AbstractPredicateFieldScoreIT(SimpleMappedIndex index, DataSet dataSet) { - super( index, dataSet ); - this.index = index; - this.dataSet = dataSet; - } - - @Test - public void fieldLevelBoost() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void fieldLevelBoost(SimpleMappedIndex index, DataSet dataSet) { assertThatQuery( index.query() .where( f -> f.or( - predicate( f, field0Path(), 0 ), - predicateWithFieldLevelBoost( f, field0Path(), 42f, 1 ) ) ) + predicate( f, field0Path( index, dataSet ), 0, dataSet ), + predicateWithFieldLevelBoost( f, field0Path( index, dataSet ), 42f, 1, dataSet ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 1 ), dataSet.docId( 0 ) ); assertThatQuery( index.query() .where( f -> f.or( - predicateWithFieldLevelBoost( f, field0Path(), 42f, 0 ), - predicate( f, field0Path(), 1 ) ) ) + predicateWithFieldLevelBoost( f, field0Path( index, dataSet ), 42f, 0, dataSet ), + predicate( f, field0Path( index, dataSet ), 1, dataSet ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 0 ), dataSet.docId( 1 ) ); } - @Test - public void predicateLevelBoost_fieldLevelBoost() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void predicateLevelBoost_fieldLevelBoost(SimpleMappedIndex index, DataSet dataSet) { assertThatQuery( index.query() .where( f -> f.or( // 2 * 2 => boost x4 - predicateWithFieldLevelBoostAndPredicateLevelBoost( f, field0Path(), 2f, - 0, 2f ), + predicateWithFieldLevelBoostAndPredicateLevelBoost( f, field0Path( index, dataSet ), 2f, + 0, 2f, dataSet + ), // 3 * 3 => boost x9 - predicateWithFieldLevelBoostAndPredicateLevelBoost( f, field0Path(), 3f, - 1, 3f ) ) ) + predicateWithFieldLevelBoostAndPredicateLevelBoost( f, field0Path( index, dataSet ), 3f, + 1, 3f, dataSet + ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 1 ), dataSet.docId( 0 ) ); assertThatQuery( index.query() .where( f -> f.or( // 1 * 3 => boost x3 - predicateWithFieldLevelBoostAndPredicateLevelBoost( f, field0Path(), 1f, - 0, 3f ), + predicateWithFieldLevelBoostAndPredicateLevelBoost( f, field0Path( index, dataSet ), 1f, + 0, 3f, dataSet + ), // 0.1 * 3 => boost x0.3 - predicateWithFieldLevelBoostAndPredicateLevelBoost( f, field0Path(), 0.1f, - 1, 3f ) ) ) + predicateWithFieldLevelBoostAndPredicateLevelBoost( f, field0Path( index, dataSet ), 0.1f, + 1, 3f, dataSet + ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 0 ), dataSet.docId( 1 ) ); } - @Test - public void constantScore_fieldLevelBoost() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void constantScore_fieldLevelBoost(SimpleMappedIndex index, DataSet dataSet) { assumeConstantScoreSupported(); SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> predicateWithFieldLevelBoostAndConstantScore( f, field0Path(), 2.1f, - 0 ) + assertThatThrownBy( () -> predicateWithFieldLevelBoostAndConstantScore( f, field0Path( index, dataSet ), 2.1f, + 0, dataSet + ) .toPredicate() ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid use of per-field boost: the predicate score is constant.", "Cannot assign a different boost to each field when the predicate score is constant." ); } - @Test - public void predicateLevelBoost_multiFields() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void predicateLevelBoost_multiFields(SimpleMappedIndex index, DataSet dataSet) { assertThatQuery( index.query() .where( f -> f.or( - predicateWithPredicateLevelBoost( f, new String[] { field0Path(), field1Path() }, - 0, 7f ), - predicateWithPredicateLevelBoost( f, new String[] { field0Path(), field1Path() }, - 1, 39f ) ) ) + predicateWithPredicateLevelBoost( f, new String[] { + field0Path( index, dataSet ), + field1Path( + index, dataSet ) }, + 0, 7f, dataSet + ), + predicateWithPredicateLevelBoost( f, new String[] { + field0Path( index, dataSet ), + field1Path( + index, dataSet ) }, + 1, 39f, dataSet + ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 1 ), dataSet.docId( 0 ) ); assertThatQuery( index.query() .where( f -> f.or( - predicateWithPredicateLevelBoost( f, new String[] { field0Path(), field1Path() }, - 0, 39f ), - predicateWithPredicateLevelBoost( f, new String[] { field0Path(), field1Path() }, - 1, 7f ) ) ) + predicateWithPredicateLevelBoost( f, new String[] { + field0Path( index, dataSet ), + field1Path( + index, dataSet ) }, + 0, 39f, dataSet + ), + predicateWithPredicateLevelBoost( f, new String[] { + field0Path( index, dataSet ), + field1Path( + index, dataSet ) }, + 1, 7f, dataSet + ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 0 ), dataSet.docId( 1 ) ); } + @SuppressWarnings("unchecked") @Override - protected final PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { - return predicate( f, field0Path(), matchingDocOrdinal ); + protected final PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return predicate( + f, field0Path( (SimpleMappedIndex) index, (DataSet) dataSet ), matchingDocOrdinal, + (DataSet) dataSet + ); } + @SuppressWarnings("unchecked") @Override - protected final PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, float boost) { - return predicateWithPredicateLevelBoost( f, new String[] { field0Path() }, - matchingDocOrdinal, boost ); + protected final PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, float boost, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return predicateWithPredicateLevelBoost( f, new String[] { + field0Path( + (SimpleMappedIndex) index, + (DataSet) dataSet + ) + }, + matchingDocOrdinal, boost, (DataSet) dataSet + ); } + @SuppressWarnings("unchecked") @Override - protected final PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { - return predicateWithConstantScore( f, new String[] { field0Path() }, - matchingDocOrdinal ); + protected final PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return predicateWithConstantScore( f, + new String[] { field0Path( (SimpleMappedIndex) index, (DataSet) dataSet ) }, + matchingDocOrdinal, (DataSet) dataSet + ); } + @SuppressWarnings("unchecked") @Override protected final PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { - return predicateWithConstantScoreAndPredicateLevelBoost( f, new String[] { field0Path() }, - matchingDocOrdinal, boost ); + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return predicateWithConstantScoreAndPredicateLevelBoost( f, + new String[] { field0Path( (SimpleMappedIndex) index, (DataSet) dataSet ) }, + matchingDocOrdinal, boost, (DataSet) dataSet + ); } protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, - int matchingDocOrdinal); + int matchingDocOrdinal, DataSet dataSet); protected abstract PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal); + String[] fieldPaths, int matchingDocOrdinal, DataSet dataSet); protected abstract PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost); + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet); protected abstract PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost); + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet); protected abstract PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal); + String fieldPath, float fieldBoost, int matchingDocOrdinal, DataSet dataSet); protected abstract PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost); + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet); protected abstract PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal); + String fieldPath, float fieldBoost, int matchingDocOrdinal, DataSet dataSet); - private String field0Path() { + private String field0Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().field0.get( dataSet.fieldType ).relativeFieldName; } - private String field1Path() { + private String field1Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().field1.get( dataSet.fieldType ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateInObjectFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateInObjectFieldIT.java index 862b5cac88f..1cf158b57be 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateInObjectFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateInObjectFieldIT.java @@ -26,109 +26,126 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateInObjectFieldIT { static final int MISSING_FIELD_INDEX_DOC_ORDINAL = 42; - protected final SimpleMappedIndex mainIndex; - protected final SimpleMappedIndex missingFieldIndex; - protected final IndexBinding binding; - protected final AbstractPredicateDataSet dataSet; - - public AbstractPredicateInObjectFieldIT(SimpleMappedIndex mainIndex, + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void flattenedX1(SimpleMappedIndex mainIndex, SimpleMappedIndex missingFieldIndex, AbstractPredicateDataSet dataSet) { - this.mainIndex = mainIndex; - this.missingFieldIndex = missingFieldIndex; - this.binding = mainIndex.binding(); - this.dataSet = dataSet; - } - - @Test - public void flattenedX1() { assertThatQuery( mainIndex.query() - .where( f -> predicate( f, binding.flattened, 0 ) ) + .where( f -> predicate( f, mainIndex.binding().flattened, 0, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test - public void flattenedX2() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void flattenedX2(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> predicate( f, binding.flattened.flattened, 0 ) ) + .where( f -> predicate( f, mainIndex.binding().flattened.flattened, 0, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test - public void nestedX1_explicit() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void nestedX1_explicit(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> f.nested( binding.nested.absolutePath ) - .add( predicate( f, binding.nested, 0 ) ) ) + .where( f -> f.nested( mainIndex.binding().nested.absolutePath ) + .add( predicate( f, mainIndex.binding().nested, 0, dataSet ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test - public void nestedX1_implicit() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void nestedX1_implicit(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> predicate( f, binding.nested, 0 ) ) + .where( f -> predicate( f, mainIndex.binding().nested, 0, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test - public void nestedX2_explicit() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void nestedX2_explicit(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> f.nested( binding.nested.absolutePath ) - .add( f.nested( binding.nested.nested.absolutePath ) - .add( predicate( f, binding.nested.nested, 0 ) ) ) ) + .where( f -> f.nested( mainIndex.binding().nested.absolutePath ) + .add( f.nested( mainIndex.binding().nested.nested.absolutePath ) + .add( predicate( f, mainIndex.binding().nested.nested, 0, dataSet ) ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test - public void nestedX2_implicit() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void nestedX2_implicit(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> predicate( f, binding.nested.nested, 0 ) ) + .where( f -> predicate( f, mainIndex.binding().nested.nested, 0, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test - public void nestedX2_explicit_implicit() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void nestedX2_explicit_implicit(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> f.nested( binding.nested.absolutePath ) - .add( predicate( f, binding.nested.nested, 0 ) ) ) + .where( f -> f.nested( mainIndex.binding().nested.absolutePath ) + .add( predicate( f, mainIndex.binding().nested.nested, 0, dataSet ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test - public void nestedX3_explicitX2_implicit() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void nestedX3_explicitX2_implicit(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> f.nested( binding.nested.absolutePath ) - .add( f.nested( binding.nested.nested.absolutePath ) - .add( predicate( f, binding.nested.nested.nested, 0 ) ) ) ) + .where( f -> f.nested( mainIndex.binding().nested.absolutePath ) + .add( f.nested( mainIndex.binding().nested.nested.absolutePath ) + .add( predicate( f, mainIndex.binding().nested.nested.nested, 0, dataSet ) ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test - public void nestedX3_explicit_implicitX2() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void nestedX3_explicit_implicitX2(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> f.nested( binding.nested.absolutePath ) - .add( predicate( f, binding.nested.nested.nested, 0 ) ) ) + .where( f -> f.nested( mainIndex.binding().nested.absolutePath ) + .add( predicate( f, mainIndex.binding().nested.nested.nested, 0, dataSet ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test - public void nestedFlattenedNested_implicit() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void nestedFlattenedNested_implicit(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> predicate( f, mainIndex.binding().nested.flattened.nested, 0 ) ) + .where( f -> predicate( f, mainIndex.binding().nested.flattened.nested, 0, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } @@ -137,14 +154,17 @@ public void nestedFlattenedNested_implicit() { * Test that no failure occurs when an implicit nested predicate targets a nested field * that only exists in one of the targeted indexes. */ - @Test + @ParameterizedTest(name = "{2}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_missingNestedField_implicit() { + void multiIndex_missingNestedField_implicit(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); // The "nested" predicate should not match anything in missingFieldIndex assertThatQuery( scope.query() - .where( f -> predicate( f, binding.nested.nested, 0 ) ) + .where( f -> predicate( f, mainIndex.binding().nested.nested, 0, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); @@ -152,7 +172,7 @@ public void multiIndex_missingNestedField_implicit() { // if the "nested" predicate is optional, it should be ignored for missingFieldIndex. assertThatQuery( scope.query() .where( f -> f.or( - predicate( f, binding.nested.nested, 0 ), + predicate( f, mainIndex.binding().nested.nested, 0, dataSet ), f.id().matching( dataSet.docId( MISSING_FIELD_INDEX_DOC_ORDINAL ) ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( c -> c @@ -162,7 +182,7 @@ public void multiIndex_missingNestedField_implicit() { } protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, ObjectFieldBinding objectFieldBinding, - int matchingDocOrdinal); + int matchingDocOrdinal, AbstractPredicateDataSet dataSet); abstract static class AbstractObjectBinding { final String absolutePath; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateInvalidFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateInvalidFieldIT.java index bb0fe00ba4f..403575a1485 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateInvalidFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateInvalidFieldIT.java @@ -16,7 +16,7 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class AbstractPredicateInvalidFieldIT { @@ -27,7 +27,7 @@ protected AbstractPredicateInvalidFieldIT(SimpleMappedIndex index) } @Test - public void unknownField() { + void unknownField() { SearchPredicateFactory f = index.createScope().predicate(); assertThatThrownBy( () -> tryPredicate( f, "unknown_field" ) ) @@ -37,7 +37,7 @@ public void unknownField() { } @Test - public void objectField_nested() { + void objectField_nested() { SearchPredicateFactory f = index.createScope().predicate(); String fieldPath = index.binding().nested.relativeFieldName; @@ -48,7 +48,7 @@ public void objectField_nested() { } @Test - public void objectField_flattened() { + void objectField_flattened() { SearchPredicateFactory f = index.createScope().predicate(); String fieldPath = index.binding().flattened.relativeFieldName; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateMultiFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateMultiFieldIT.java index 4980629f100..dd14322e88f 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateMultiFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateMultiFieldIT.java @@ -19,87 +19,94 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateMultiFieldIT> { - private final SimpleMappedIndex index; - protected final DataSet dataSet; - - protected AbstractPredicateMultiFieldIT(SimpleMappedIndex index, DataSet dataSet) { - this.index = index; - this.dataSet = dataSet; - } - - @Test - public void fieldAndField() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void fieldAndField(SimpleMappedIndex index, DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicateOnFieldAndField( f, field0Path(), field1Path(), - 0 ) ) + .where( f -> predicateOnFieldAndField( f, field0Path( index, dataSet ), field1Path( index, dataSet ), + 0, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); assertThatQuery( index.query() - .where( f -> predicateOnFieldAndField( f, field0Path(), field1Path(), - 1 ) ) + .where( f -> predicateOnFieldAndField( f, field0Path( index, dataSet ), field1Path( index, dataSet ), + 1, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 1 ) ); } - @Test - public void fields() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void fields(SimpleMappedIndex index, DataSet dataSet) { assertThatQuery( index.query() .where( f -> predicateOnFields( f, - new String[] { field0Path(), field1Path() }, 0 ) ) + new String[] { field0Path( index, dataSet ), field1Path( index, dataSet ) }, 0, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); assertThatQuery( index.query() .where( f -> predicateOnFields( f, - new String[] { field0Path(), field1Path() }, 1 ) ) + new String[] { field0Path( index, dataSet ), field1Path( index, dataSet ) }, 1, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 1 ) ); } - @Test - public void fieldAndFields() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void fieldAndFields(SimpleMappedIndex index, DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicateOnFieldAndFields( f, field0Path(), - new String[] { field1Path(), field2Path() }, - 0 ) ) + .where( f -> predicateOnFieldAndFields( f, field0Path( index, dataSet ), + new String[] { field1Path( index, dataSet ), field2Path( index, dataSet ) }, + 0, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); assertThatQuery( index.query() - .where( f -> predicateOnFieldAndFields( f, field0Path(), new String[] { field1Path(), field2Path() }, - 1 ) ) + .where( f -> predicateOnFieldAndFields( f, field0Path( index, dataSet ), new String[] { + field1Path( + index, dataSet ), + field2Path( index, dataSet ) }, + 1, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 1 ) ); if ( dataSet.hasMoreThanTwoValues() ) { // Booleans have only two values... assertThatQuery( index.query() - .where( f -> predicateOnFieldAndFields( f, field0Path(), - new String[] { field1Path(), field2Path() }, 2 ) ) + .where( f -> predicateOnFieldAndFields( f, field0Path( index, dataSet ), + new String[] { field1Path( index, dataSet ), field2Path( index, dataSet ) }, 2, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 2 ) ); } } protected abstract PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal); + String otherFieldPath, int matchingDocOrdinal, DataSet dataSet); protected abstract PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal); + int matchingDocOrdinal, + DataSet dataSet); protected abstract PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal); + String[] fieldPaths, int matchingDocOrdinal, DataSet dataSet); - private String field0Path() { + private String field0Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().field0.get( dataSet.fieldType ).relativeFieldName; } - private String field1Path() { + private String field1Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().field1.get( dataSet.fieldType ).relativeFieldName; } - private String field2Path() { + private String field2Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().field2.get( dataSet.fieldType ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateScaleCheckingIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateScaleCheckingIT.java index d445dcf2dc3..151cc6e7fbc 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateScaleCheckingIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateScaleCheckingIT.java @@ -24,7 +24,7 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class AbstractPredicateScaleCheckingIT { @@ -44,7 +44,7 @@ protected AbstractPredicateScaleCheckingIT(SimpleMappedIndex index } @Test - public void multiIndex_withCompatibleIndex() { + void multiIndex_withCompatibleIndex() { StubMappingScope scope = index.createScope( compatibleIndex ); assertThatQuery( scope.query() @@ -63,7 +63,7 @@ public void multiIndex_withCompatibleIndex() { } @Test - public void multiIndex_withIncompatibleIndex() { + void multiIndex_withIncompatibleIndex() { StubMappingScope scope = index.createScope( incompatibleIndex ); assertThatThrownBy( () -> predicate( scope.predicate(), bigDecimalFieldPath(), dataSet.bigDecimal0 ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateScoreIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateScoreIT.java index 39935632a7a..7cd6da33d08 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateScoreIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateScoreIT.java @@ -12,86 +12,87 @@ import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateScoreIT { - private final StubMappedIndex index; - private final AbstractPredicateDataSet dataSet; - public AbstractPredicateScoreIT(StubMappedIndex index, AbstractPredicateDataSet dataSet) { - this.index = index; - this.dataSet = dataSet; - } - - @Test - public void predicateLevelBoost() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void predicateLevelBoost(StubMappedIndex index, AbstractPredicateDataSet dataSet) { assertThatQuery( index.query() .where( f -> f.or( - predicate( f, 0 ), - predicateWithBoost( f, 1, 7f ) ) ) + predicate( f, 0, dataSet, index ), + predicateWithBoost( f, 1, 7f, dataSet, index ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 1 ), dataSet.docId( 0 ) ); assertThatQuery( index.query() .where( f -> f.or( - predicateWithBoost( f, 0, 39f ), - predicate( f, 1 ) ) ) + predicateWithBoost( f, 0, 39f, dataSet, index ), + predicate( f, 1, dataSet, index ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 0 ), dataSet.docId( 1 ) ); } - @Test - public void constantScore() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void constantScore(StubMappedIndex index, AbstractPredicateDataSet dataSet) { assumeConstantScoreSupported(); assertThatQuery( index.query() .where( f -> f.or( // Very low boost, so score << 1 - predicateWithBoost( f, 0, 0.01f ), + predicateWithBoost( f, 0, 0.01f, dataSet, index ), // Constant score, so score = 1 - predicateWithConstantScore( f, 1 ) ) ) + predicateWithConstantScore( f, 1, dataSet, index ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 1 ), dataSet.docId( 0 ) ); assertThatQuery( index.query() .where( f -> f.or( // Constant score, so score = 1 - predicateWithConstantScore( f, 0 ), + predicateWithConstantScore( f, 0, dataSet, index ), // Very low boost, so score << 1 - predicateWithBoost( f, 1, 0.01f ) ) ) + predicateWithBoost( f, 1, 0.01f, dataSet, index ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 0 ), dataSet.docId( 1 ) ); } - @Test - public void constantScore_predicateLevelBoost() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void constantScore_predicateLevelBoost(StubMappedIndex index, AbstractPredicateDataSet dataSet) { assumeConstantScoreSupported(); assertThatQuery( index.query() .where( f -> f.or( - predicateWithConstantScoreAndBoost( f, 0, 7f ), - predicateWithConstantScoreAndBoost( f, 1, 39f ) ) ) + predicateWithConstantScoreAndBoost( f, 0, 7f, dataSet, index ), + predicateWithConstantScoreAndBoost( f, 1, 39f, dataSet, index ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 1 ), dataSet.docId( 0 ) ); assertThatQuery( index.query() .where( f -> f.or( - predicateWithConstantScoreAndBoost( f, 0, 39f ), - predicateWithConstantScoreAndBoost( f, 1, 7f ) ) ) + predicateWithConstantScoreAndBoost( f, 0, 39f, dataSet, index ), + predicateWithConstantScoreAndBoost( f, 1, 7f, dataSet, index ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.docId( 0 ), dataSet.docId( 1 ) ); } - protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal); + protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index); protected abstract PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost); + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index); protected abstract PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, - int matchingDocOrdinal); + int matchingDocOrdinal, AbstractPredicateDataSet dataSet, + StubMappedIndex index); protected abstract PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost); + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index); protected void assumeConstantScoreSupported() { // By default we assume constant score IS supported. diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSearchableIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSearchableIT.java index c0b44c06fa6..c63ed871a25 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSearchableIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSearchableIT.java @@ -18,24 +18,16 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateSearchableIT { - private final SimpleMappedIndex searchableYesIndex; - private final SimpleMappedIndex searchableNoIndex; - private final FieldTypeDescriptor fieldType; - - protected AbstractPredicateSearchableIT(SimpleMappedIndex searchableYesIndex, + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void unsearchable(SimpleMappedIndex searchableYesIndex, SimpleMappedIndex searchableNoIndex, FieldTypeDescriptor fieldType) { - this.searchableYesIndex = searchableYesIndex; - this.searchableNoIndex = searchableNoIndex; - this.fieldType = fieldType; - } - - @Test - public void unsearchable() { SearchPredicateFactory f = searchableNoIndex.createScope().predicate(); String fieldPath = searchableNoIndex.binding().field.get( fieldType ).relativeFieldName; @@ -48,8 +40,11 @@ public void unsearchable() { ); } - @Test - public void multiIndex_incompatibleSearchable() { + @ParameterizedTest(name = "{2}") + @MethodSource("params") + void multiIndex_incompatibleSearchable(SimpleMappedIndex searchableYesIndex, + SimpleMappedIndex searchableNoIndex, + FieldTypeDescriptor fieldType) { SearchPredicateFactory f = searchableYesIndex.createScope( searchableNoIndex ).predicate(); String fieldPath = searchableYesIndex.binding().field.get( fieldType ).relativeFieldName; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSimpleAnalysisIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSimpleAnalysisIT.java index 8e07c9c6068..63bd2e88402 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSimpleAnalysisIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSimpleAnalysisIT.java @@ -29,7 +29,7 @@ import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Integration tests for simple analysis support in predicates, @@ -54,7 +54,7 @@ protected AbstractPredicateSimpleAnalysisIT(SimpleMappedIndex inde @Test @PortedFromSearch5(original = "org.hibernate.search.test.dsl.SimpleQueryStringDSLTest.testEmptyQueryString") - public void emptyStringBeforeAnalysis() { + void emptyStringBeforeAnalysis() { assertThatQuery( index.query() .where( f -> predicate( f, index.binding().analyzedStringField.relativeFieldName, "" ) ) ) .hasNoHits(); @@ -63,14 +63,14 @@ public void emptyStringBeforeAnalysis() { @Test @TestForIssue(jiraKey = "HSEARCH-2700") @PortedFromSearch5(original = "org.hibernate.search.test.dsl.SimpleQueryStringDSLTest.testBlankQueryString") - public void blankStringBeforeAnalysis() { + void blankStringBeforeAnalysis() { assertThatQuery( index.query() .where( f -> predicate( f, index.binding().analyzedStringField.relativeFieldName, " " ) ) ) .hasNoHits(); } @Test - public void noTokenAfterAnalysis() { + void noTokenAfterAnalysis() { assertThatQuery( index.query() // Use a stopword, which should be removed by the analysis .where( f -> predicate( f, index.binding().analyzedStringField.relativeFieldName, "a" ) ) ) @@ -78,7 +78,7 @@ public void noTokenAfterAnalysis() { } @Test - public void multiIndex_incompatibleAnalyzer() { + void multiIndex_incompatibleAnalyzer() { StubMappingScope scope = index.createScope( incompatibleSearchAnalyzerIndex ); String absoluteFieldPath = index.binding().analyzedStringField.relativeFieldName; @@ -97,7 +97,7 @@ public void multiIndex_incompatibleAnalyzer() { } @Test - public void multiIndex_incompatibleAnalyzer_searchAnalyzer() { + void multiIndex_incompatibleAnalyzer_searchAnalyzer() { StubMappingScope scope = index.createScope( compatibleSearchAnalyzerIndex ); String absoluteFieldPath = index.binding().analyzedStringField.relativeFieldName; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSingleFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSingleFieldIT.java index ad3a7daef07..ceba6f3f993 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSingleFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateSingleFieldIT.java @@ -19,34 +19,29 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; // TODO HSEARCH-3593 test multiple field structures (in nested, ...) public abstract class AbstractPredicateSingleFieldIT> { - private final SimpleMappedIndex index; - protected final DataSet dataSet; - - protected AbstractPredicateSingleFieldIT(SimpleMappedIndex index, DataSet dataSet) { - this.index = index; - this.dataSet = dataSet; - } - - @Test - public void match() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void match(SimpleMappedIndex index, DataSet dataSet) { int valueCount = dataSet.values.size(); for ( int i = 0; i < valueCount; i++ ) { int matchingDocOrdinal = i; assertThatQuery( index.query() - .where( f -> predicate( f, fieldPath(), matchingDocOrdinal ) ) + .where( f -> predicate( f, fieldPath( index, dataSet ), matchingDocOrdinal, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( i ) ); } } - protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal); + protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet); - private String fieldPath() { + private String fieldPath(SimpleMappedIndex index, DataSet dataSet) { return index.binding().field.get( dataSet.fieldType ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateTypeCheckingAndConversionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateTypeCheckingAndConversionIT.java index 59c16ff2965..d160e10f613 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateTypeCheckingAndConversionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateTypeCheckingAndConversionIT.java @@ -33,200 +33,278 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateTypeCheckingAndConversionIT, P> { - private final SimpleMappedIndex index; - private final SimpleMappedIndex compatibleIndex; - private final SimpleMappedIndex rawFieldCompatibleIndex; - private final SimpleMappedIndex missingFieldIndex; - private final SimpleMappedIndex incompatibleIndex; - protected final DataSet dataSet; - - protected AbstractPredicateTypeCheckingAndConversionIT(SimpleMappedIndex index, + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void defaultDslConverter_valueConvertDefault_validType(SimpleMappedIndex index, SimpleMappedIndex compatibleIndex, SimpleMappedIndex rawFieldCompatibleIndex, SimpleMappedIndex missingFieldIndex, SimpleMappedIndex incompatibleIndex, DataSet dataSet) { - this.index = index; - this.compatibleIndex = compatibleIndex; - this.rawFieldCompatibleIndex = rawFieldCompatibleIndex; - this.missingFieldIndex = missingFieldIndex; - this.incompatibleIndex = incompatibleIndex; - this.dataSet = dataSet; - } - - @Test - public void defaultDslConverter_valueConvertDefault_validType() { assertThatQuery( index.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), - unwrappedMatchingParam( 0 ) ) ) + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), + unwrappedMatchingParam( 0, dataSet ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); } - @Test - public void defaultDslConverter_valueConvertDefault_invalidType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void defaultDslConverter_valueConvertDefault_invalidType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> predicate( f, defaultDslConverterField0Path(), invalidTypeParam() ) ) + assertThatThrownBy( () -> predicate( f, defaultDslConverterField0Path( index, dataSet ), invalidTypeParam() ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Unable to convert DSL argument: " ) .hasMessageContaining( InvalidType.class.getName() ) .hasCauseInstanceOf( ClassCastException.class ) .satisfies( FailureReportUtils.hasContext( - EventContexts.fromIndexFieldAbsolutePath( defaultDslConverterField0Path() ) + EventContexts.fromIndexFieldAbsolutePath( defaultDslConverterField0Path( index, dataSet ) ) ) ); } - @Test - public void customDslConverter_valueConvertDefault_validType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void customDslConverter_valueConvertDefault_validType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), wrappedMatchingParam( 0 ) ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), wrappedMatchingParam( 0, + dataSet + ) ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); } - @Test - public void customDslConverter_valueConvertDefault_invalidType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void customDslConverter_valueConvertDefault_invalidType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> predicate( f, customDslConverterField0Path(), invalidTypeParam() ) ) + assertThatThrownBy( () -> predicate( f, customDslConverterField0Path( index, dataSet ), invalidTypeParam() ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Unable to convert DSL argument: " ) .hasMessageContaining( InvalidType.class.getName() ) .hasCauseInstanceOf( ClassCastException.class ) .satisfies( FailureReportUtils.hasContext( - EventContexts.fromIndexFieldAbsolutePath( customDslConverterField0Path() ) + EventContexts.fromIndexFieldAbsolutePath( customDslConverterField0Path( index, dataSet ) ) ) ); } - @Test - public void defaultDslConverter_valueConvertYes_validType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void defaultDslConverter_valueConvertYes_validType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), - unwrappedMatchingParam( 0 ), ValueConvert.YES ) ) + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), + unwrappedMatchingParam( 0, dataSet ), ValueConvert.YES ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); } - @Test - public void defaultDslConverter_valueConvertYes_invalidType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void defaultDslConverter_valueConvertYes_invalidType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> predicate( f, defaultDslConverterField0Path(), invalidTypeParam(), + assertThatThrownBy( () -> predicate( f, defaultDslConverterField0Path( index, dataSet ), invalidTypeParam(), ValueConvert.YES ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Unable to convert DSL argument: " ) .hasMessageContaining( InvalidType.class.getName() ) .hasCauseInstanceOf( ClassCastException.class ) .satisfies( FailureReportUtils.hasContext( - EventContexts.fromIndexFieldAbsolutePath( defaultDslConverterField0Path() ) + EventContexts.fromIndexFieldAbsolutePath( defaultDslConverterField0Path( index, dataSet ) ) ) ); } - @Test - public void customDslConverter_valueConvertYes_validType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void customDslConverter_valueConvertYes_validType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), - wrappedMatchingParam( 0 ), ValueConvert.YES ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), + wrappedMatchingParam( 0, dataSet ), ValueConvert.YES ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); } - @Test - public void customDslConverter_valueConvertYes_invalidType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void customDslConverter_valueConvertYes_invalidType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> predicate( f, customDslConverterField0Path(), invalidTypeParam(), + assertThatThrownBy( () -> predicate( f, customDslConverterField0Path( index, dataSet ), invalidTypeParam(), ValueConvert.YES ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Unable to convert DSL argument: " ) .hasMessageContaining( InvalidType.class.getName() ) .hasCauseInstanceOf( ClassCastException.class ) .satisfies( FailureReportUtils.hasContext( - EventContexts.fromIndexFieldAbsolutePath( customDslConverterField0Path() ) + EventContexts.fromIndexFieldAbsolutePath( customDslConverterField0Path( index, dataSet ) ) ) ); } - @Test - public void defaultDslConverter_valueConvertNo_validType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void defaultDslConverter_valueConvertNo_validType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), - unwrappedMatchingParam( 0 ), ValueConvert.NO ) ) + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), + unwrappedMatchingParam( 0, dataSet ), ValueConvert.NO ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); } - @Test - public void defaultDslConverter_valueConvertNo_invalidType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void defaultDslConverter_valueConvertNo_invalidType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> predicate( f, defaultDslConverterField0Path(), invalidTypeParam(), + assertThatThrownBy( () -> predicate( f, defaultDslConverterField0Path( index, dataSet ), invalidTypeParam(), ValueConvert.NO ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Unable to convert DSL argument: " ) .hasMessageContaining( InvalidType.class.getName() ) .hasCauseInstanceOf( ClassCastException.class ) .satisfies( FailureReportUtils.hasContext( - EventContexts.fromIndexFieldAbsolutePath( defaultDslConverterField0Path() ) + EventContexts.fromIndexFieldAbsolutePath( defaultDslConverterField0Path( index, dataSet ) ) ) ); } - @Test - public void customDslConverter_valueConvertNo_validType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void customDslConverter_valueConvertNo_validType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), - unwrappedMatchingParam( 0 ), ValueConvert.NO ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), + unwrappedMatchingParam( 0, dataSet ), ValueConvert.NO ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); } - @Test - public void customDslConverter_valueConvertNo_invalidType() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void customDslConverter_valueConvertNo_invalidType(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> predicate( f, customDslConverterField0Path(), invalidTypeParam(), + assertThatThrownBy( () -> predicate( f, customDslConverterField0Path( index, dataSet ), invalidTypeParam(), ValueConvert.NO ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Unable to convert DSL argument: " ) .hasMessageContaining( InvalidType.class.getName() ) .hasCauseInstanceOf( ClassCastException.class ) .satisfies( FailureReportUtils.hasContext( - EventContexts.fromIndexFieldAbsolutePath( customDslConverterField0Path() ) + EventContexts.fromIndexFieldAbsolutePath( customDslConverterField0Path( index, dataSet ) ) ) ); } - @Test - public void multiFields_customDslConverter_valueConvertYes() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiFields_customDslConverter_valueConvertYes(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), customDslConverterField1Path(), - wrappedMatchingParam( 0 ), ValueConvert.YES ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), customDslConverterField1Path( + index, dataSet ), + wrappedMatchingParam( 0, dataSet ), ValueConvert.YES ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), customDslConverterField1Path(), - wrappedMatchingParam( 1 ), ValueConvert.YES ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), customDslConverterField1Path( + index, dataSet ), + wrappedMatchingParam( 1, dataSet ), ValueConvert.YES ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 1 ) ); } - @Test - public void multiFields_customDslConverter_valueConvertNo() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiFields_customDslConverter_valueConvertNo(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), customDslConverterField1Path(), - unwrappedMatchingParam( 0 ), ValueConvert.NO ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), customDslConverterField1Path( + index, dataSet ), + unwrappedMatchingParam( 0, dataSet ), ValueConvert.NO ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), customDslConverterField1Path(), - unwrappedMatchingParam( 1 ), ValueConvert.NO ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), customDslConverterField1Path( + index, dataSet ), + unwrappedMatchingParam( 1, dataSet ), ValueConvert.NO ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 1 ) ); } - @Test - public void multiIndex_withCompatibleIndex_valueConvertYes() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiIndex_withCompatibleIndex_valueConvertYes(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( compatibleIndex ); assertThatQuery( scope.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), unwrappedMatchingParam( 0 ), + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), unwrappedMatchingParam( 0, + dataSet + ), ValueConvert.YES ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( b -> { @@ -235,14 +313,20 @@ public void multiIndex_withCompatibleIndex_valueConvertYes() { } ); } - @Test - public void multiIndex_withRawFieldCompatibleIndex_valueConvertYes() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiIndex_withRawFieldCompatibleIndex_valueConvertYes(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( rawFieldCompatibleIndex ); - String fieldPath = defaultDslConverterField0Path(); + String fieldPath = defaultDslConverterField0Path( index, dataSet ); assertThatThrownBy( () -> predicate( scope.predicate(), fieldPath, - unwrappedMatchingParam( 0 ), ValueConvert.YES ) ) + unwrappedMatchingParam( 0, dataSet ), ValueConvert.YES ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Inconsistent configuration for field '" + fieldPath + "' in a search query across multiple indexes", @@ -253,13 +337,19 @@ public void multiIndex_withRawFieldCompatibleIndex_valueConvertYes() { ) ); } - @Test - public void multiIndex_withRawFieldCompatibleIndex_valueConvertNo() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiIndex_withRawFieldCompatibleIndex_valueConvertNo(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( rawFieldCompatibleIndex ); assertThatQuery( scope.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), - unwrappedMatchingParam( 0 ), ValueConvert.NO ) ) + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), + unwrappedMatchingParam( 0, dataSet ), ValueConvert.NO ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( b -> { b.doc( index.typeName(), dataSet.docId( 0 ) ); @@ -271,14 +361,22 @@ public void multiIndex_withRawFieldCompatibleIndex_valueConvertNo() { * Test that no failure occurs when a predicate targets a field * that only exists in one of the targeted indexes. */ - @Test + @ParameterizedTest(name = "{5}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex_valueConvertYes() { + void multiIndex_withMissingFieldIndex_valueConvertYes(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( missingFieldIndex ); // The predicate should not match anything in missingFieldIndex assertThatQuery( scope.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), unwrappedMatchingParam( 0 ), + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), unwrappedMatchingParam( 0, + dataSet + ), ValueConvert.YES ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( b -> { @@ -289,7 +387,8 @@ public void multiIndex_withMissingFieldIndex_valueConvertYes() { // if the predicate is optional, it should be ignored for missingFieldIndex. assertThatQuery( scope.query() .where( f -> f.or( - predicate( f, defaultDslConverterField0Path(), unwrappedMatchingParam( 0 ), ValueConvert.YES ), + predicate( f, defaultDslConverterField0Path( index, dataSet ), unwrappedMatchingParam( 0, dataSet ), + ValueConvert.YES ), f.id().matching( dataSet.docId( DataSet.MISSING_FIELD_INDEX_DOC_ORDINAL ) ) ) ) ) .hasDocRefHitsAnyOrder( c -> c .doc( index.typeName(), dataSet.docId( 0 ) ) @@ -301,14 +400,22 @@ public void multiIndex_withMissingFieldIndex_valueConvertYes() { * Test that no failure occurs when a predicate targets a field * that only exists in one of the targeted indexes. */ - @Test + @ParameterizedTest(name = "{5}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex_valueConvertNo() { + void multiIndex_withMissingFieldIndex_valueConvertNo(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( missingFieldIndex ); // The predicate should not match anything in missingFieldIndex assertThatQuery( scope.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), unwrappedMatchingParam( 0 ), + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), unwrappedMatchingParam( 0, + dataSet + ), ValueConvert.NO ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( b -> { @@ -319,7 +426,8 @@ public void multiIndex_withMissingFieldIndex_valueConvertNo() { // if the predicate is optional, it should be ignored for missingFieldIndex. assertThatQuery( scope.query() .where( f -> f.or( - predicate( f, defaultDslConverterField0Path(), unwrappedMatchingParam( 0 ), ValueConvert.NO ), + predicate( f, defaultDslConverterField0Path( index, dataSet ), unwrappedMatchingParam( 0, dataSet ), + ValueConvert.NO ), f.id().matching( dataSet.docId( DataSet.MISSING_FIELD_INDEX_DOC_ORDINAL ) ) ) ) ) .hasDocRefHitsAnyOrder( c -> c .doc( index.typeName(), dataSet.docId( 0 ) ) @@ -327,14 +435,20 @@ public void multiIndex_withMissingFieldIndex_valueConvertNo() { .hasTotalHitCount( 2 ); } - @Test - public void multiIndex_withIncompatibleIndex_valueConvertYes() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex_valueConvertYes(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( incompatibleIndex ); - String fieldPath = defaultDslConverterField0Path(); + String fieldPath = defaultDslConverterField0Path( index, dataSet ); assertThatThrownBy( () -> predicate( scope.predicate(), fieldPath, - unwrappedMatchingParam( 0 ), ValueConvert.YES ) ) + unwrappedMatchingParam( 0, dataSet ), ValueConvert.YES ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Inconsistent configuration for field '" + fieldPath + "' in a search query across multiple indexes", @@ -345,14 +459,20 @@ public void multiIndex_withIncompatibleIndex_valueConvertYes() { ) ); } - @Test - public void multiIndex_withIncompatibleIndex_valueConvertNo() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex_valueConvertNo(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( incompatibleIndex ); - String fieldPath = defaultDslConverterField0Path(); + String fieldPath = defaultDslConverterField0Path( index, dataSet ); assertThatThrownBy( () -> predicate( scope.predicate(), fieldPath, - unwrappedMatchingParam( 0 ), ValueConvert.NO ) ) + unwrappedMatchingParam( 0, dataSet ), ValueConvert.NO ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Inconsistent configuration for field '" + fieldPath + "' in a search query across multiple indexes", @@ -373,21 +493,21 @@ protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, String protected abstract P invalidTypeParam(); - protected abstract P unwrappedMatchingParam(int matchingDocOrdinal); + protected abstract P unwrappedMatchingParam(int matchingDocOrdinal, DataSet dataSet); - protected abstract P wrappedMatchingParam(int matchingDocOrdinal); + protected abstract P wrappedMatchingParam(int matchingDocOrdinal, DataSet dataSet); protected abstract String predicateNameInErrorMessage(); - private String defaultDslConverterField0Path() { + private String defaultDslConverterField0Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().defaultDslConverterField0.get( dataSet.fieldType ).relativeFieldName; } - private String customDslConverterField0Path() { + private String customDslConverterField0Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().customDslConverterField0.get( dataSet.fieldType ).relativeFieldName; } - private String customDslConverterField1Path() { + private String customDslConverterField1Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().customDslConverterField1.get( dataSet.fieldType ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateTypeCheckingNoConversionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateTypeCheckingNoConversionIT.java index b689c7a7bd1..aff007806d6 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateTypeCheckingNoConversionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateTypeCheckingNoConversionIT.java @@ -33,62 +33,65 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateTypeCheckingNoConversionIT> { - private final SimpleMappedIndex index; - private final SimpleMappedIndex compatibleIndex; - private final SimpleMappedIndex rawFieldCompatibleIndex; - private final SimpleMappedIndex missingFieldIndex; - private final SimpleMappedIndex incompatibleIndex; - protected final DataSet dataSet; - - protected AbstractPredicateTypeCheckingNoConversionIT(SimpleMappedIndex index, + // DSL converters should be ignored + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void customDslConverter(SimpleMappedIndex index, SimpleMappedIndex compatibleIndex, SimpleMappedIndex rawFieldCompatibleIndex, SimpleMappedIndex missingFieldIndex, SimpleMappedIndex incompatibleIndex, DataSet dataSet) { - this.index = index; - this.compatibleIndex = compatibleIndex; - this.rawFieldCompatibleIndex = rawFieldCompatibleIndex; - this.missingFieldIndex = missingFieldIndex; - this.incompatibleIndex = incompatibleIndex; - this.dataSet = dataSet; - } - - // DSL converters should be ignored - @Test - public void customDslConverter() { assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), - 0 ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), + 0, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); } // DSL converters, and their incompatibility, should be ignored - @Test - public void multiFields_customDslConverter() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiFields_customDslConverter(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), customDslConverterField1Path(), - 0 ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), customDslConverterField1Path( + index, dataSet ), + 0, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 0 ) ); assertThatQuery( index.query() - .where( f -> predicate( f, customDslConverterField0Path(), customDslConverterField1Path(), - 1 ) ) + .where( f -> predicate( f, customDslConverterField0Path( index, dataSet ), customDslConverterField1Path( + index, dataSet ), + 1, dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.docId( 1 ) ); } - @Test - public void multiIndex_withCompatibleIndex() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiIndex_withCompatibleIndex(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( compatibleIndex ); assertThatQuery( scope.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), 0 ) ) + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), 0, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( b -> { b.doc( index.typeName(), dataSet.docId( 0 ) ); @@ -97,12 +100,18 @@ public void multiIndex_withCompatibleIndex() { } // DSL converters, and their incompatibility, should be ignored - @Test - public void multiIndex_withRawFieldCompatibleIndex() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiIndex_withRawFieldCompatibleIndex(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( rawFieldCompatibleIndex ); assertThatQuery( scope.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), 0 ) ) + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), 0, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( b -> { b.doc( index.typeName(), dataSet.docId( 0 ) ); @@ -114,14 +123,20 @@ public void multiIndex_withRawFieldCompatibleIndex() { * Test that no failure occurs when a predicate targets a field * that only exists in one of the targeted indexes. */ - @Test + @ParameterizedTest(name = "{5}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex() { + void multiIndex_withMissingFieldIndex(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( missingFieldIndex ); // The predicate should not match anything in missingFieldIndex assertThatQuery( scope.query() - .where( f -> predicate( f, defaultDslConverterField0Path(), 0 ) ) + .where( f -> predicate( f, defaultDslConverterField0Path( index, dataSet ), 0, dataSet ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( b -> { b.doc( index.typeName(), dataSet.docId( 0 ) ); @@ -131,7 +146,7 @@ public void multiIndex_withMissingFieldIndex() { // if the predicate is optional, it should be ignored for missingFieldIndex. assertThatQuery( scope.query() .where( f -> f.or( - predicate( f, defaultDslConverterField0Path(), 0 ), + predicate( f, defaultDslConverterField0Path( index, dataSet ), 0, dataSet ), f.id().matching( dataSet.docId( DataSet.MISSING_FIELD_INDEX_DOC_ORDINAL ) ) ) ) ) .hasDocRefHitsAnyOrder( c -> c .doc( index.typeName(), dataSet.docId( 0 ) ) @@ -140,14 +155,21 @@ public void multiIndex_withMissingFieldIndex() { } // Fields with a different type *are* a problem, though. - @Test - public void multiIndex_withIncompatibleIndex() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet dataSet) { StubMappingScope scope = index.createScope( incompatibleIndex ); - String fieldPath = defaultDslConverterField0Path(); + String fieldPath = defaultDslConverterField0Path( index, dataSet ); assertThatThrownBy( () -> predicate( scope.predicate(), fieldPath, - 0 ) ) + 0, dataSet + ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Inconsistent configuration for field '" + fieldPath + "' in a search query across multiple indexes", @@ -158,22 +180,23 @@ public void multiIndex_withIncompatibleIndex() { ) ); } - protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal); + protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet); protected abstract PredicateFinalStep predicate(SearchPredicateFactory f, String field0Path, String field1Path, - int matchingDocOrdinal); + int matchingDocOrdinal, DataSet dataSet); protected abstract String predicateNameInErrorMessage(); - protected final String defaultDslConverterField0Path() { + protected final String defaultDslConverterField0Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().defaultDslConverterField0.get( dataSet.fieldType ).relativeFieldName; } - private String customDslConverterField0Path() { + private String customDslConverterField0Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().customDslConverterField0.get( dataSet.fieldType ).relativeFieldName; } - private String customDslConverterField1Path() { + private String customDslConverterField1Path(SimpleMappedIndex index, DataSet dataSet) { return index.binding().customDslConverterField1.get( dataSet.fieldType ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateUnsupportedTypeIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateUnsupportedTypeIT.java index f6600b0fbb6..42ac481069e 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateUnsupportedTypeIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractPredicateUnsupportedTypeIT.java @@ -19,20 +19,14 @@ import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public abstract class AbstractPredicateUnsupportedTypeIT { - private final SimpleMappedIndex index; - private final FieldTypeDescriptor fieldType; - - protected AbstractPredicateUnsupportedTypeIT(SimpleMappedIndex index, FieldTypeDescriptor fieldType) { - this.index = index; - this.fieldType = fieldType; - } - - @Test - public void unsupported() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void unsupported(SimpleMappedIndex index, FieldTypeDescriptor fieldType) { SearchPredicateFactory f = index.createScope().predicate(); String fieldPath = index.binding().field.get( fieldType ).relativeFieldName; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractSpatialWithinPredicateIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractSpatialWithinPredicateIT.java index 2100d07ff2e..b756338e417 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractSpatialWithinPredicateIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AbstractSpatialWithinPredicateIT.java @@ -12,11 +12,11 @@ import org.hibernate.search.engine.backend.types.Searchable; import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.engine.spatial.GeoPoint; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.RegisterExtension; public abstract class AbstractSpatialWithinPredicateIT { @@ -34,8 +34,8 @@ public abstract class AbstractSpatialWithinPredicateIT { protected static final String EMPTY_ID = "empty"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); protected final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -45,8 +45,8 @@ public abstract class AbstractSpatialWithinPredicateIT { protected final SimpleMappedIndex unsearchableFieldsIndex = SimpleMappedIndex.of( UnsearchableFieldsIndexBinding::new ).name( "unsearchableFields" ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndexes( mainIndex, compatibleIndex, unsearchableFieldsIndex ).setup(); initData(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AndPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AndPredicateBaseIT.java index 7df77eb8957..32c48693ce1 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AndPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AndPredicateBaseIT.java @@ -6,27 +6,30 @@ */ package org.hibernate.search.integrationtest.backend.tck.search.predicate; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class AndPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class AndPredicateBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( ScoreIT.index, @@ -44,43 +47,42 @@ public static void setup() { addScoreIndexer.join(); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class ScoreIT extends AbstractPredicateScoreIT { + class ScoreIT extends AbstractPredicateScoreIT { private static final DataSet dataSet = new DataSet(); private static final StubMappedIndex index = StubMappedIndex.withoutFields().name( "score" ); - public ScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.and( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.and( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ); } @Override protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { - return f.and( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.and( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.and( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.and( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { - return f.and( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.and( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore() .boost( boost ); } @@ -99,40 +101,44 @@ public void contribute(BulkIndexer scoreIndexer) { } @Nested - public static class AddScoreIT extends AbstractPredicateScoreIT { + class AddScoreIT extends AbstractPredicateScoreIT { private static final DataSet dataSet = new DataSet(); private static final StubMappedIndex index = StubMappedIndex.withoutFields().name( "addscore" ); - public AddScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { return f.and() - .add( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ); + .add( f.id().matching( AddScoreIT.dataSet.docId( matchingDocOrdinal ) ) ); } @Override protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { - return f.and( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.and( f.id().matching( AddScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { return f.and() - .add( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + .add( f.id().matching( AddScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { return f.and() - .add( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + .add( f.id().matching( AddScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore() .boost( boost ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AndPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AndPredicateSpecificsIT.java index a77345ff76e..fc67d1d43c9 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AndPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/AndPredicateSpecificsIT.java @@ -13,16 +13,16 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.types.dsl.IndexFieldTypeFactory; import org.hibernate.search.engine.search.predicate.SearchPredicate; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class AndPredicateSpecificsIT { +class AndPredicateSpecificsIT { private static final String DOCUMENT_1 = "1"; private static final String DOCUMENT_2 = "2"; @@ -52,27 +52,27 @@ public class AndPredicateSpecificsIT { private static final Integer FIELD4_VALUE3 = 42_000; // Different from document 1 private static final Integer FIELD5_VALUE3 = 142_000; // Different from document 1 - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void empty() { + void empty() { assertThatQuery( index.query() .where( f -> f.and() ) ) .hasNoHits(); } @Test - public void and() { + void and() { assertThatQuery( index.query() .where( f -> f.and( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); @@ -93,7 +93,7 @@ public void and() { } @Test - public void and_separatePredicateObject() { + void and_separatePredicateObject() { StubMappingScope scope = index.createScope(); SearchPredicate predicate1 = scope.predicate().match().field( "field1" ).matching( FIELD1_VALUE1 ).toPredicate(); @@ -120,7 +120,7 @@ public void and_separatePredicateObject() { } @Test - public void nested() { + void nested() { assertThatQuery( index.query() .where( f -> f.and( f.or( f.match().field( "field1" ).matching( FIELD1_VALUE1 ), @@ -130,7 +130,7 @@ public void nested() { } @Test - public void add() { + void add() { assertThatQuery( index.query() .where( f -> f.and() .add( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) ) ) @@ -150,7 +150,7 @@ public void add() { } @Test - public void add_separatePredicateObject() { + void add_separatePredicateObject() { StubMappingScope scope = index.createScope(); SearchPredicate predicate1 = scope.predicate().match().field( "field1" ).matching( FIELD1_VALUE1 ).toPredicate(); @@ -176,7 +176,7 @@ public void add_separatePredicateObject() { } @Test - public void add_function() { + void add_function() { assertThatQuery( index.query() .where( f -> f.and() .add( f2 -> f2.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) ) ) @@ -196,7 +196,7 @@ public void add_function() { } @Test - public void where() { + void where() { assertThatQuery( index.query() .where( (f, root) -> { root.add( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ); @@ -219,7 +219,7 @@ public void where() { } @Test - public void with() { + void with() { assertThatQuery( index.query() .where( f -> f.and().with( and -> and.add( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) ) ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); @@ -239,7 +239,7 @@ public void with() { } @Test - public void hasClause() { + void hasClause() { StubMappingScope scope = index.createScope(); assertThat( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/BoolPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/BoolPredicateBaseIT.java index d84651c7dfc..b09c4f3dc18 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/BoolPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/BoolPredicateBaseIT.java @@ -6,27 +6,30 @@ */ package org.hibernate.search.integrationtest.backend.tck.search.predicate; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class BoolPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class BoolPredicateBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( ScoreIT.index @@ -39,43 +42,42 @@ public static void setup() { scoreIndexer.join(); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class ScoreIT extends AbstractPredicateScoreIT { + class ScoreIT extends AbstractPredicateScoreIT { private static final DataSet dataSet = new DataSet(); private static final StubMappedIndex index = StubMappedIndex.withoutFields().name( "score" ); - public ScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.bool().should( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.bool().should( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ); } @Override protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { - return f.bool().should( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.bool().should( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.bool().should( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.bool().should( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { - return f.bool().should( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.bool().should( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore().boost( boost ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/BoolPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/BoolPredicateSpecificsIT.java index 95a2096d39e..a088bc45e53 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/BoolPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/BoolPredicateSpecificsIT.java @@ -17,18 +17,18 @@ import org.hibernate.search.engine.search.predicate.SearchPredicate; import org.hibernate.search.engine.search.predicate.dsl.MinimumShouldMatchConditionStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class BoolPredicateSpecificsIT { +class BoolPredicateSpecificsIT { private static final String DOCUMENT_1 = "1"; private static final String DOCUMENT_2 = "2"; @@ -58,27 +58,27 @@ public class BoolPredicateSpecificsIT { private static final Integer FIELD4_VALUE3 = 42_000; // Different from document 1 private static final Integer FIELD5_VALUE3 = 142_000; // Different from document 1 - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void noClause() { + void noClause() { assertThatQuery( index.query() .where( f -> f.bool() ) ) .hasNoHits(); } @Test - public void must() { + void must() { assertThatQuery( index.query() .where( f -> f.bool() .must( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -101,7 +101,7 @@ public void must() { } @Test - public void must_function() { + void must_function() { assertThatQuery( index.query() .where( f -> f.bool() .must( f2 -> f2.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -110,7 +110,7 @@ public void must_function() { } @Test - public void must_separatePredicateObject() { + void must_separatePredicateObject() { StubMappingScope scope = index.createScope(); SearchPredicate predicate = scope.predicate().match().field( "field1" ).matching( FIELD1_VALUE1 ).toPredicate(); @@ -121,7 +121,7 @@ public void must_separatePredicateObject() { } @Test - public void should() { + void should() { assertThatQuery( index.query() .where( f -> f.bool() .should( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -137,7 +137,7 @@ public void should() { } @Test - public void should_function() { + void should_function() { assertThatQuery( index.query() .where( f -> f.bool() .should( f2 -> f2.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -147,7 +147,7 @@ public void should_function() { } @Test - public void should_separatePredicateObject() { + void should_separatePredicateObject() { StubMappingScope scope = index.createScope(); SearchPredicate predicate1 = scope.predicate().match().field( "field1" ).matching( FIELD1_VALUE1 ).toPredicate(); @@ -162,7 +162,7 @@ public void should_separatePredicateObject() { } @Test - public void mustNot() { + void mustNot() { assertThatQuery( index.query() .where( f -> f.bool() .mustNot( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -178,7 +178,7 @@ public void mustNot() { } @Test - public void mustNot_function() { + void mustNot_function() { assertThatQuery( index.query() .where( f -> f.bool() .mustNot( f2 -> f2.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -187,7 +187,7 @@ public void mustNot_function() { } @Test - public void mustNot_separatePredicateObject() { + void mustNot_separatePredicateObject() { StubMappingScope scope = index.createScope(); SearchPredicate predicate = scope.predicate().match().field( "field1" ).matching( FIELD1_VALUE2 ).toPredicate(); @@ -200,7 +200,7 @@ public void mustNot_separatePredicateObject() { } @Test - public void filter() { + void filter() { assertThatQuery( index.query() .where( f -> f.bool() .filter( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -223,7 +223,7 @@ public void filter() { } @Test - public void filter_function() { + void filter_function() { assertThatQuery( index.query() .where( f -> f.bool() .filter( f2 -> f2.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -232,7 +232,7 @@ public void filter_function() { } @Test - public void filter_separatePredicateObject() { + void filter_separatePredicateObject() { StubMappingScope scope = index.createScope(); SearchPredicate predicate = scope.predicate().match().field( "field1" ).matching( FIELD1_VALUE1 ).toPredicate(); @@ -243,7 +243,7 @@ public void filter_separatePredicateObject() { } @Test - public void should_mustNot() { + void should_mustNot() { assertThatQuery( index.query() .where( f -> f.bool() .should( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -254,7 +254,7 @@ public void should_mustNot() { } @Test - public void must_mustNot() { + void must_mustNot() { assertThatQuery( index.query() .where( f -> f.bool() .must( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) @@ -271,7 +271,7 @@ public void must_mustNot() { } @Test - public void nested() { + void nested() { assertThatQuery( index.query() .where( f -> f.bool() .must( f.bool() @@ -291,7 +291,7 @@ public void nested() { } @Test - public void must_should() { + void must_should() { // A boolean predicate with must + should clauses: // documents should match regardless of whether should clauses match. @@ -315,7 +315,7 @@ public void must_should() { } @Test - public void filter_should() { + void filter_should() { // A boolean predicate with filter + should clauses: // documents should match regardless of whether should clauses match. @@ -339,7 +339,7 @@ public void filter_should() { } @Test - public void mustNot_should() { + void mustNot_should() { // A boolean predicate with mustNot + should clauses: // documents should match only if at least one should clause matches @@ -365,7 +365,7 @@ public void mustNot_should() { } @Test - public void with() { + void with() { assertThatQuery( index.query() .where( f -> f.bool().with( b -> { b.should( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ); @@ -386,7 +386,7 @@ public void with() { @Test @SuppressWarnings("deprecation") - public void lambda() { + void lambda() { assertThatQuery( index.query() .where( f -> f.bool( b -> { b.should( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ); @@ -396,7 +396,7 @@ public void lambda() { } @Test - public void minimumShouldMatchNumber_positive() { + void minimumShouldMatchNumber_positive() { // Expect default behavior (1 "should" clause has to match) assertThatQuery( index.query() .where( f -> f.bool() @@ -437,7 +437,7 @@ public void minimumShouldMatchNumber_positive() { } @Test - public void minimumShouldMatchNumber_negative() { + void minimumShouldMatchNumber_negative() { // Expect default behavior (1 "should" clause has to match) assertThatQuery( index.query() .where( f -> f.bool() @@ -469,7 +469,7 @@ public void minimumShouldMatchNumber_negative() { } @Test - public void minimumShouldMatchPercent_positive() { + void minimumShouldMatchPercent_positive() { // Expect default behavior (1 "should" clause has to match) assertThatQuery( index.query() .where( f -> f.bool() @@ -510,7 +510,7 @@ public void minimumShouldMatchPercent_positive() { } @Test - public void minimumShouldMatchPercent_negative() { + void minimumShouldMatchPercent_negative() { // Expect default behavior (1 "should" clause has to match) assertThatQuery( index.query() .where( f -> f.bool() @@ -542,7 +542,7 @@ public void minimumShouldMatchPercent_negative() { } @Test - public void minimumShouldMatch_multipleConstraints() { + void minimumShouldMatch_multipleConstraints() { Consumer> minimumShouldMatchConstraints = b -> b .ifMoreThan( 2 ).thenRequireNumber( -1 ) .ifMoreThan( 4 ).thenRequirePercent( 70 ); @@ -620,7 +620,7 @@ public void minimumShouldMatch_multipleConstraints() { } @Test - public void minimumShouldMatch_multipleConstraints_0ceiling() { + void minimumShouldMatch_multipleConstraints_0ceiling() { Consumer> minimumShouldMatchConstraints = b -> b // Test that we can set the "default" minimum by using a ceiling of 0 .ifMoreThan( 0 ).thenRequireNumber( 1 ) @@ -658,7 +658,7 @@ public void minimumShouldMatch_multipleConstraints_0ceiling() { } @Test - public void minimumShouldMatch_error_negativeCeiling() { + void minimumShouldMatch_error_negativeCeiling() { SearchPredicateFactory f = index.createScope().predicate(); assertThatThrownBy( () -> f.bool().minimumShouldMatch() @@ -675,7 +675,7 @@ public void minimumShouldMatch_error_negativeCeiling() { } @Test - public void minimumShouldMatch_error_multipleConflictingCeilings() { + void minimumShouldMatch_error_multipleConflictingCeilings() { SearchPredicateFactory f = index.createScope().predicate(); assertThatThrownBy( () -> f.bool().minimumShouldMatch() @@ -689,7 +689,7 @@ public void minimumShouldMatch_error_multipleConflictingCeilings() { @Test @TestForIssue(jiraKey = "HSEARCH-3534") - public void minimumShouldMatch_default() { + void minimumShouldMatch_default() { // If the should is alone ( not having any sibling must ), // the default minimum should match will be 1. assertThatQuery( index.query() @@ -721,7 +721,7 @@ public void minimumShouldMatch_default() { @Test @TestForIssue(jiraKey = "HSEARCH-3534") - public void minimumShouldMatch_default_withinFilter_mustSibling() { + void minimumShouldMatch_default_withinFilter_mustSibling() { // We're following here the Lucene's conventions. // If the should has a sibling must, even if the should is inside a filter, // the default minimum should match will be 0. @@ -736,7 +736,7 @@ public void minimumShouldMatch_default_withinFilter_mustSibling() { } @Test - public void minimumShouldMatch_default_withinFilter_mustNotSibling() { + void minimumShouldMatch_default_withinFilter_mustNotSibling() { // Differently from must predicate, // if the should has a sibling must-not inside a filter, // the default minimum should match will be still 1. @@ -751,7 +751,7 @@ public void minimumShouldMatch_default_withinFilter_mustNotSibling() { } @Test - public void minimumShouldMatch_default_withinFilter_filterSibling() { + void minimumShouldMatch_default_withinFilter_filterSibling() { // We're following here the Lucene's conventions. // If the should has a sibling filter, even if the should is inside a filter, // the default minimum should match will be 0. @@ -766,7 +766,7 @@ public void minimumShouldMatch_default_withinFilter_filterSibling() { } @Test - public void hasClause() { + void hasClause() { StubMappingScope scope = index.createScope(); assertThat( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateBaseIT.java index 23ecd1d78d5..69cd0126f74 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateBaseIT.java @@ -15,29 +15,28 @@ import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; +import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.AssumptionViolatedException; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class ExistsPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class ExistsPredicateBaseIT { + //CHECKSTYLE:ON private static final List> supportedFieldTypes = FieldTypeDescriptor.getAll(); - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, @@ -91,94 +90,80 @@ private static ExistsPredicateTestValues testValues(FieldTypeDescriptor( fieldType ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT> { + class SingleFieldIT extends AbstractPredicateSingleFieldIT> { + + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "singleField" ); private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "singleField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public SingleFieldIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.exists().field( fieldPath ); } } @Nested - @RunWith(Parameterized.class) - public static class ScoreIT extends AbstractPredicateScoreIT { + class ScoreIT extends AbstractPredicateScoreIT { + + private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) + .name( "score" ); private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( fieldType ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) - .name( "score" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - protected final DataSet dataSet; - - public ScoreIT(DataSet dataSet) { - super( index, dataSet ); - this.dataSet = dataSet; - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.exists().field( fieldPath( matchingDocOrdinal ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.exists().field( fieldPath( matchingDocOrdinal, dataSet ) ); } @Override protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { - return f.exists().field( fieldPath( matchingDocOrdinal ) ).boost( boost ); + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.exists().field( fieldPath( matchingDocOrdinal, dataSet ) ).boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.exists().field( fieldPath( matchingDocOrdinal ) ).constantScore(); + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.exists().field( fieldPath( matchingDocOrdinal, dataSet ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { - return f.exists().field( fieldPath( matchingDocOrdinal ) ).constantScore().boost( boost ); + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.exists().field( fieldPath( matchingDocOrdinal, dataSet ) ).constantScore().boost( boost ); } - private String fieldPath(int matchingDocOrdinal) { + @SuppressWarnings("unchecked") + private String fieldPath(int matchingDocOrdinal, AbstractPredicateDataSet dataSet) { SimpleFieldModelsByType field; switch ( matchingDocOrdinal ) { case 0: @@ -190,7 +175,7 @@ private String fieldPath(int matchingDocOrdinal) { default: throw new IllegalStateException( "This test only works with up to two documents" ); } - return field.get( dataSet.fieldType ).relativeFieldName; + return field.get( ( (DataSet) dataSet ).fieldType ).relativeFieldName; } private static class IndexBinding { @@ -222,18 +207,7 @@ public void contribute(BulkIndexer scoreIndexer) { } @Nested - @RunWith(Parameterized.class) - public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT> { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT> { private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "nesting" ); @@ -242,17 +216,23 @@ public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFie SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); + } } - public InObjectFieldIT(DataSet> dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { if ( matchingDocOrdinal != 0 ) { throw new IllegalStateException( "This predicate can only match the first document" ); } @@ -261,7 +241,7 @@ protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPat } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -271,12 +251,12 @@ public InvalidFieldIT() { @Override public void objectField_flattened() { - throw new AssumptionViolatedException( "The 'exists' predicate actually can be used on object fields" ); + throw new org.opentest4j.TestAbortedException( "The 'exists' predicate actually can be used on object fields" ); } @Override public void objectField_nested() { - throw new AssumptionViolatedException( "The 'exists' predicate actually can be used on object fields" ); + throw new org.opentest4j.TestAbortedException( "The 'exists' predicate actually can be used on object fields" ); } @Override @@ -291,14 +271,7 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class SearchableIT extends AbstractPredicateSearchableIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) @@ -308,18 +281,23 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( searchableYesIndex, searchableNoIndex, fieldType ) ); + } } - public SearchableIT(FieldTypeDescriptor fieldType) { - super( searchableYesIndex, searchableNoIndex, fieldType ); + public static List params() { + return parameters; } @Override - public void unsearchable() { - throw new AssumptionViolatedException( "The 'exists' predicate actually can be used on unsearchable fields" ); + public void unsearchable(SimpleMappedIndex searchableYesIndex, + SimpleMappedIndex searchableNoIndex, + FieldTypeDescriptor fieldType) { + throw new org.opentest4j.TestAbortedException( + "The 'exists' predicate actually can be used on unsearchable fields" ); } @Override @@ -334,24 +312,8 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class TypeCheckingNoConversionIT + class TypeCheckingNoConversionIT extends AbstractPredicateTypeCheckingNoConversionIT> { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; - } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_main" ); @@ -376,25 +338,42 @@ protected void addIrrelevantOptions(FieldTypeDescriptor fieldType, SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - public TypeCheckingNoConversionIT(DataSet> dataSet) { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, + incompatibleIndex, dataSet ) ); + } + } + + public static List params() { + return parameters; } @Override - public void multiIndex_withIncompatibleIndex() { - throw new AssumptionViolatedException( "The 'exists' predicate actually can be used when a field relies" + public void multiIndex_withIncompatibleIndex(SimpleMappedIndex index, + SimpleMappedIndex compatibleIndex, + SimpleMappedIndex rawFieldCompatibleIndex, + SimpleMappedIndex missingFieldIndex, + SimpleMappedIndex incompatibleIndex, + DataSet> dataSet) { + throw new org.opentest4j.TestAbortedException( "The 'exists' predicate actually can be used when a field relies" + " on different codecs in different indexes" ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.exists().field( fieldPath ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, String field0Path, String field1Path, - int matchingDocOrdinal) { - throw new AssumptionViolatedException( "The 'exists' predicate can only target one field at a time" ); + int matchingDocOrdinal, DataSet> dataSet) { + throw new org.opentest4j.TestAbortedException( "The 'exists' predicate can only target one field at a time" ); } @Override @@ -404,7 +383,7 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class ScaleCheckingIT extends AbstractPredicateScaleCheckingIT { + class ScaleCheckingIT extends AbstractPredicateScaleCheckingIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) @@ -421,7 +400,7 @@ public ScaleCheckingIT() { @Override public void multiIndex_withIncompatibleIndex() { - throw new AssumptionViolatedException( "The 'exists' predicate actually can be used when a field relies" + throw new org.opentest4j.TestAbortedException( "The 'exists' predicate actually can be used when a field relies" + " on different codecs in different indexes" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateObjectsBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateObjectsBaseIT.java index 32344b270cb..bbe58d3486f 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateObjectsBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateObjectsBaseIT.java @@ -25,30 +25,32 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.AnalyzedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.function.TriFunction; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; +import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(NestedRunner.class) -public class ExistsPredicateObjectsBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class ExistsPredicateObjectsBaseIT { + //CHECKSTYLE:ON private static final FieldTypeDescriptor innerFieldType = AnalyzedStringFieldTypeDescriptor.INSTANCE; - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( InObjectFieldIT.mainIndex, InObjectFieldIT.missingFieldIndex, @@ -66,23 +68,8 @@ public static void setup() { inObjectFieldMainIndexer.join( inObjectFieldMissingFieldIndexer, scoreIndexer ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class InObjectFieldIT extends AbstractPredicateInObjectFieldIT { - private static final List dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( ObjectStructure structure : Arrays.asList( ObjectStructure.NESTED, ObjectStructure.FLATTENED ) ) { - DataSet dataSet = new DataSet( structure ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } + class InObjectFieldIT extends AbstractPredicateInObjectFieldIT { private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, Collections.singletonList( innerFieldType ) ) ) @@ -92,52 +79,65 @@ public static class InObjectFieldIT extends AbstractPredicateInObjectFieldIT { SimpleMappedIndex .of( root -> new MissingFieldIndexBinding( root, Collections.singletonList( innerFieldType ) ) ) .name( "nesting_missingField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( ObjectStructure structure : Arrays.asList( ObjectStructure.NESTED, ObjectStructure.FLATTENED ) ) { + DataSet dataSet = new DataSet( structure ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); + } } - private final DataSet dataSet; - - public InObjectFieldIT(DataSet dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); - this.dataSet = dataSet; + public static List params() { + return parameters; } - @Test + @ParameterizedTest(name = "{2}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void factoryWithRoot_nested() { + void factoryWithRoot_nested(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> predicateWithRelativePath( f.withRoot( binding.nested.absolutePath ), binding.nested ) ) + .where( f -> predicateWithRelativePath( f.withRoot( mainIndex.binding().nested.absolutePath ), + mainIndex.binding().nested, + dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } - @Test + @ParameterizedTest(name = "{2}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void factoryWithRoot_flattened() { + void factoryWithRoot_flattened(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingFieldIndex, + AbstractPredicateDataSet dataSet) { assertThatQuery( mainIndex.query() - .where( f -> predicateWithRelativePath( f.withRoot( binding.flattened.absolutePath ), binding.flattened ) ) + .where( f -> predicateWithRelativePath( f.withRoot( mainIndex.binding().flattened.absolutePath ), + mainIndex.binding().flattened, + dataSet + ) ) .routing( dataSet.routingKey ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, ObjectFieldBinding objectFieldBinding, - int matchingDocOrdinal) { + int matchingDocOrdinal, AbstractPredicateDataSet dataSet) { if ( matchingDocOrdinal != 0 ) { throw new IllegalStateException( "This predicate can only match the first document" ); } - return f.exists().field( targetField( objectFieldBinding ).absolutePath ); + return f.exists().field( targetField( objectFieldBinding, ( (DataSet) dataSet ) ).absolutePath ); } - protected PredicateFinalStep predicateWithRelativePath(SearchPredicateFactory f, - ObjectFieldBinding objectFieldBinding) { - return f.exists().field( targetField( objectFieldBinding ).relativeName ); + protected PredicateFinalStep predicateWithRelativePath(SearchPredicateFactory f, ObjectFieldBinding objectFieldBinding, + AbstractPredicateDataSet dataSet) { + return f.exists().field( targetField( objectFieldBinding, ( (DataSet) dataSet ) ).relativeName ); } - private ObjectFieldBinding targetField(ObjectFieldBinding objectFieldBinding) { + private ObjectFieldBinding targetField(ObjectFieldBinding objectFieldBinding, DataSet dataSet) { switch ( dataSet.structure ) { case FLATTENED: return objectFieldBinding.flattened; @@ -167,56 +167,50 @@ public void contribute(BulkIndexer mainIndexer, BulkIndexer missingFieldIndexer) } @Nested - @RunWith(Parameterized.class) - public static class ScoreIT extends AbstractPredicateScoreIT { + class ScoreIT extends AbstractPredicateScoreIT { + private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) + .name( "score" ); private static final List dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( ObjectStructure structure : ObjectStructure.values() ) { DataSet dataSet = new DataSet( structure ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) - .name( "score" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - protected final DataSet dataSet; - - public ScoreIT(DataSet dataSet) { - super( index, dataSet ); - this.dataSet = dataSet; - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.exists().field( fieldPath( matchingDocOrdinal ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.exists().field( fieldPath( matchingDocOrdinal, dataSet ) ); } @Override protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { - return f.exists().field( fieldPath( matchingDocOrdinal ) ).boost( boost ); + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.exists().field( fieldPath( matchingDocOrdinal, dataSet ) ).boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.exists().field( fieldPath( matchingDocOrdinal ) ).constantScore(); + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.exists().field( fieldPath( matchingDocOrdinal, dataSet ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { - return f.exists().field( fieldPath( matchingDocOrdinal ) ).constantScore().boost( boost ); + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.exists().field( fieldPath( matchingDocOrdinal, dataSet ) ).constantScore().boost( boost ); } - private String fieldPath(int matchingDocOrdinal) { + private String fieldPath(int matchingDocOrdinal, AbstractPredicateDataSet dataSet) { Map field; switch ( matchingDocOrdinal ) { case 0: @@ -228,7 +222,7 @@ private String fieldPath(int matchingDocOrdinal) { default: throw new IllegalStateException( "This test only works with up to two documents" ); } - return field.get( dataSet.structure ).relativeFieldName; + return field.get( ( (DataSet) dataSet ).structure ).relativeFieldName; } private static class IndexBinding { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateObjectsSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateObjectsSpecificsIT.java index 669f497667a..da6ecb158cd 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateObjectsSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateObjectsSpecificsIT.java @@ -17,18 +17,18 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.reporting.spi.EventContexts; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ExistsPredicateObjectsSpecificsIT { +class ExistsPredicateObjectsSpecificsIT { // this document is empty private static final String DOCUMENT_0 = "0"; @@ -60,8 +60,8 @@ public class ExistsPredicateObjectsSpecificsIT { public static final String ANY_STRING = "Any String"; public static final int ANY_INTEGER = 173173; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -82,8 +82,8 @@ public class ExistsPredicateObjectsSpecificsIT { .name( "differentInnerNestedField" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( mainIndex, compatibleIndex, emptyIndex, @@ -96,7 +96,7 @@ public static void setup() { } @Test - public void nested() { + void nested() { assertThatQuery( mainIndex.query() .where( f -> f.exists().field( "nested" ) ) ) // DOCUMENT_2 won't be matched either, since it hasn't got any not-null field @@ -105,14 +105,14 @@ public void nested() { } @Test - public void nested_noChild() { + void nested_noChild() { assertThatQuery( mainIndex.query() .where( f -> f.exists().field( "nestedNoChild" ) ) ) .hasNoHits(); } @Test - public void nested_multiIndexes_compatibleIndexBinding() { + void nested_multiIndexes_compatibleIndexBinding() { StubMappingScope scope = mainIndex.createScope( compatibleIndex ); assertThatQuery( scope.query() @@ -123,7 +123,7 @@ public void nested_multiIndexes_compatibleIndexBinding() { } @Test - public void nested_multiIndexes_incompatibleIndexBinding() { + void nested_multiIndexes_incompatibleIndexBinding() { SearchPredicateFactory f = mainIndex.createScope( incompatibleIndex ).predicate(); String fieldPath = "nested"; @@ -138,7 +138,7 @@ public void nested_multiIndexes_incompatibleIndexBinding() { } @Test - public void nested_multiIndexes_emptyIndexBinding() { + void nested_multiIndexes_emptyIndexBinding() { StubMappingScope scope = mainIndex.createScope( emptyIndex ); assertThatQuery( scope.query() @@ -149,7 +149,7 @@ public void nested_multiIndexes_emptyIndexBinding() { } @Test - public void nested_multiIndexes_wrongStructure() { + void nested_multiIndexes_wrongStructure() { SearchPredicateFactory f = mainIndex.createScope( invertedIndex ).predicate(); String fieldPath = "nested"; @@ -167,7 +167,7 @@ public void nested_multiIndexes_wrongStructure() { } @Test - public void nested_multiIndexes_differentFields() { + void nested_multiIndexes_differentFields() { String fieldPath = "nested"; assertThatQuery( mainIndex.createScope( differentFieldsIndex ).query() @@ -194,7 +194,7 @@ public void nested_multiIndexes_differentFields() { } @Test - public void flattened() { + void flattened() { assertThatQuery( mainIndex.query() .where( p -> p.exists().field( "flattened" ) ) ) // DOCUMENT_2 won't be matched either, since it hasn't got any not-null field @@ -203,14 +203,14 @@ public void flattened() { } @Test - public void flattened_noChild() { + void flattened_noChild() { assertThatQuery( mainIndex.query() .where( p -> p.exists().field( "flattenedNoChild" ) ) ) .hasNoHits(); } @Test - public void flattened_multiIndexes_compatibleIndexBinding() { + void flattened_multiIndexes_compatibleIndexBinding() { assertThatQuery( mainIndex.query() .where( p -> p.exists().field( "flattened" ) ) ) // DOCUMENT_2 won't be matched either, since it hasn't got any not-null field @@ -219,7 +219,7 @@ public void flattened_multiIndexes_compatibleIndexBinding() { } @Test - public void flattened_multiIndexes_incompatibleIndexBinding() { + void flattened_multiIndexes_incompatibleIndexBinding() { SearchPredicateFactory f = incompatibleIndex.createScope( mainIndex ).predicate(); String fieldPath = "flattened"; @@ -234,7 +234,7 @@ public void flattened_multiIndexes_incompatibleIndexBinding() { } @Test - public void flattened_multiIndexes_emptyIndexBinding() { + void flattened_multiIndexes_emptyIndexBinding() { StubMappingScope scope = mainIndex.createScope( emptyIndex ); assertThatQuery( scope.query() @@ -245,7 +245,7 @@ public void flattened_multiIndexes_emptyIndexBinding() { } @Test - public void flattened_multiIndexes_wrongStructure() { + void flattened_multiIndexes_wrongStructure() { SearchPredicateFactory f = invertedIndex.createScope( mainIndex ).predicate(); String fieldPath = "flattened"; @@ -263,7 +263,7 @@ public void flattened_multiIndexes_wrongStructure() { } @Test - public void flattened_multiIndexes_differentFields() { + void flattened_multiIndexes_differentFields() { StubMappingScope scope = differentFieldsIndex.createScope( mainIndex ); String fieldPath = "flattened"; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateSpecificsIT.java index 0253d27ba4f..869d8e71ed3 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ExistsPredicateSpecificsIT.java @@ -7,8 +7,8 @@ package org.hibernate.search.integrationtest.backend.tck.search.predicate; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -26,23 +26,22 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class ExistsPredicateSpecificsIT { +class ExistsPredicateSpecificsIT { private static final List> supportedFieldTypes = FieldTypeDescriptor.getAll(); private static final List> supportedFieldTypesWithDocValues = new ArrayList<>(); private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { if ( fieldType.isFieldSortSupported() ) { @@ -50,25 +49,24 @@ public class ExistsPredicateSpecificsIT { } DataSet dataSet = new DataSet<>( fieldType ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( dataSet ) ); } } - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ) .name( "main" ); private static final SimpleMappedIndex differentFieldTypeIndex = SimpleMappedIndex.of( DifferentTypeIndexBinding::new ).name( "differentFieldType" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( mainIndex, differentFieldTypeIndex ).setup(); BulkIndexer mainIndexer = mainIndex.bulkIndexer(); @@ -77,18 +75,13 @@ public static void setup() { mainIndexer.join( differentFieldTypeIndexer ); } - private final DataSet dataSet; - - public ExistsPredicateSpecificsIT(DataSet dataSet) { - this.dataSet = dataSet; - } - /** * There's no such thing as a "missing" predicate, * but let's check that negating the "exists" predicate works as intended. */ - @Test - public void missing() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void missing(DataSet dataSet) { String fieldPath = mainIndex.binding().fieldWithDefaults.get( dataSet.fieldType ).relativeFieldName; assertThatQuery( mainIndex.query() @@ -101,9 +94,10 @@ public void missing() { * Fields with docvalues may be optimized and use a different Lucene query. * Make sure to test the optimization as well. */ - @Test - public void withDocValues() { - assumeDocValuesAllowed(); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withDocValues(DataSet dataSet) { + assumeDocValuesAllowed( dataSet ); String fieldPath = mainIndex.binding().fieldWithDocValues.get( dataSet.fieldType ).relativeFieldName; @@ -113,9 +107,10 @@ public void withDocValues() { .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ), dataSet.docId( 1 ) ); } - @Test - public void inFlattenedObject_withDocValues() { - assumeDocValuesAllowed(); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inFlattenedObject_withDocValues(DataSet dataSet) { + assumeDocValuesAllowed( dataSet ); String fieldPath = mainIndex.binding().flattenedObject.relativeFieldName + "." + mainIndex.binding().flattenedObject.fieldWithDocValues.get( dataSet.fieldType ).relativeFieldName; @@ -126,9 +121,10 @@ public void inFlattenedObject_withDocValues() { .hasDocRefHitsAnyOrder( mainIndex.typeName(), dataSet.docId( 0 ), dataSet.docId( 1 ) ); } - @Test - public void inNestedObject_withDocValues() { - assumeDocValuesAllowed(); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inNestedObject_withDocValues(DataSet dataSet) { + assumeDocValuesAllowed( dataSet ); String fieldPath = mainIndex.binding().nestedObject.relativeFieldName + "." + mainIndex.binding().nestedObject.fieldWithDocValues.get( dataSet.fieldType ).relativeFieldName; @@ -143,8 +139,9 @@ public void inNestedObject_withDocValues() { * If we require a field not to exist in a nested object, * a document will match if *any* of its nested objects lacks the field. */ - @Test - public void inNestedPredicate_missing() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void inNestedPredicate_missing(DataSet dataSet) { String fieldPath = mainIndex.binding().nestedObject.relativeFieldName + "." + mainIndex.binding().nestedObject.fieldWithDefaults.get( dataSet.fieldType ).relativeFieldName; @@ -160,10 +157,13 @@ public void inNestedPredicate_missing() { * The "exists" predicate can work with indexes whose underlying field has a different type, * provided the implementation of the exists predicate is the same (i.e. docValues, norms, ...). */ - @Test - public void multiIndex_differentFieldType() { - assumeFalse( "This test is only relevant if the field type does not use norms", - dataSet.fieldType.equals( AnalyzedStringFieldTypeDescriptor.INSTANCE ) ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_differentFieldType(DataSet dataSet) { + assumeFalse( + dataSet.fieldType.equals( AnalyzedStringFieldTypeDescriptor.INSTANCE ), + "This test is only relevant if the field type does not use norms" + ); StubMappingScope scope = mainIndex.createScope( differentFieldTypeIndex ); @@ -183,9 +183,10 @@ public void multiIndex_differentFieldType() { * The "exists" predicate can work with indexes whose underlying field has a different type, * provided the implementation of the exists predicate is the same (i.e. docValues, norms, ...). */ - @Test - public void multiIndex_differentFieldType_withDocValues() { - assumeDocValuesAllowed(); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_differentFieldType_withDocValues(DataSet dataSet) { + assumeDocValuesAllowed( dataSet ); StubMappingScope scope = mainIndex.createScope( differentFieldTypeIndex ); @@ -201,9 +202,11 @@ public void multiIndex_differentFieldType_withDocValues() { } ); } - private void assumeDocValuesAllowed() { - assumeTrue( "This test is only relevant if the field type supports doc values", - supportedFieldTypesWithDocValues.contains( dataSet.fieldType ) ); + private void assumeDocValuesAllowed(DataSet dataSet) { + assumeTrue( + supportedFieldTypesWithDocValues.contains( dataSet.fieldType ), + "This test is only relevant if the field type supports doc values" + ); } private static class IndexBinding { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchAllPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchAllPredicateBaseIT.java index 4a393877eb1..ba6fa480452 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchAllPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchAllPredicateBaseIT.java @@ -6,6 +6,7 @@ */ package org.hibernate.search.integrationtest.backend.tck.search.predicate; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -14,26 +15,26 @@ import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.AnalyzedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class MatchAllPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class MatchAllPredicateBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( InObjectFieldIT.mainIndex, InObjectFieldIT.missingFieldIndex, @@ -51,13 +52,8 @@ public static void setup() { inObjectFieldMainIndexer.join( inObjectFieldMissingFieldIndexer, scoreIndexer ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class InObjectFieldIT extends AbstractPredicateInObjectFieldIT { + class InObjectFieldIT extends AbstractPredicateInObjectFieldIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex mainIndex = @@ -68,14 +64,14 @@ public static class InObjectFieldIT extends AbstractPredicateInObjectFieldIT { SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, FieldTypeDescriptor.getAll() ) ) .name( "nesting_missingField" ); - public InObjectFieldIT() { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, ObjectFieldBinding objectFieldBinding, - int matchingDocOrdinal) { - return f.matchAll().except( f.id().matchingAny( dataSet.docIdsExcept( matchingDocOrdinal ) ) ); + int matchingDocOrdinal, AbstractPredicateDataSet dataSet) { + return f.matchAll().except( f.id().matchingAny( InObjectFieldIT.dataSet.docIdsExcept( matchingDocOrdinal ) ) ); } private static class DataSet extends AbstractPredicateDataSet { @@ -103,37 +99,41 @@ public List docIdsExcept(int docOrdinal) { } @Nested - public static class ScoreIT extends AbstractPredicateScoreIT { + class ScoreIT extends AbstractPredicateScoreIT { private static final DataSet dataSet = new DataSet(); private static final StubMappedIndex index = StubMappedIndex.withoutFields().name( "score" ); - public ScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.matchAll().except( f.id().matchingAny( dataSet.docIdsExcept( matchingDocOrdinal ) ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.matchAll().except( f.id().matchingAny( ScoreIT.dataSet.docIdsExcept( matchingDocOrdinal ) ) ); } @Override protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { - return f.matchAll().except( f.id().matchingAny( dataSet.docIdsExcept( matchingDocOrdinal ) ) ) + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.matchAll().except( f.id().matchingAny( ScoreIT.dataSet.docIdsExcept( matchingDocOrdinal ) ) ) .boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.matchAll().except( f.id().matchingAny( dataSet.docIdsExcept( matchingDocOrdinal ) ) ) + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.matchAll().except( f.id().matchingAny( ScoreIT.dataSet.docIdsExcept( matchingDocOrdinal ) ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { - return f.matchAll().except( f.id().matchingAny( dataSet.docIdsExcept( matchingDocOrdinal ) ) ) + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.matchAll().except( f.id().matchingAny( ScoreIT.dataSet.docIdsExcept( matchingDocOrdinal ) ) ) .constantScore().boost( boost ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchAllPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchAllPredicateSpecificsIT.java index be009a7795b..de09dcd0d68 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchAllPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchAllPredicateSpecificsIT.java @@ -12,14 +12,14 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.search.predicate.SearchPredicate; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MatchAllPredicateSpecificsIT { +class MatchAllPredicateSpecificsIT { private static final String DOCUMENT_1 = "1"; private static final String STRING_1 = "aaa"; @@ -30,27 +30,27 @@ public class MatchAllPredicateSpecificsIT { private static final String DOCUMENT_3 = "3"; private static final String STRING_3 = "ccc"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void matchAll() { + void matchAll() { assertThatQuery( index.query() .where( f -> f.matchAll() ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1, DOCUMENT_2, DOCUMENT_3 ); } @Test - public void except() { + void except() { assertThatQuery( index.query() .where( f -> f.matchAll().except( c2 -> c2.match().field( "string" ).matching( STRING_1 ) ) ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_2, DOCUMENT_3 ); @@ -64,7 +64,7 @@ public void except() { } @Test - public void multipleExcepts() { + void multipleExcepts() { assertThatQuery( index.query() .where( f -> f.matchAll() .except( f.match().field( "string" ).matching( STRING_1 ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateBaseIT.java index d5c9fb84452..c2e54b890d5 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateBaseIT.java @@ -6,30 +6,33 @@ */ package org.hibernate.search.integrationtest.backend.tck.search.predicate; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.AnalyzedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class MatchIdPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class MatchIdPredicateBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( InObjectFieldIT.mainIndex, InObjectFieldIT.missingFieldIndex, @@ -47,13 +50,8 @@ public static void setup() { inObjectFieldMainIndexer.join( inObjectFieldMissingFieldIndexer, scoreIndexer ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class InObjectFieldIT extends AbstractPredicateInObjectFieldIT { + class InObjectFieldIT extends AbstractPredicateInObjectFieldIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex mainIndex = @@ -64,14 +62,14 @@ public static class InObjectFieldIT extends AbstractPredicateInObjectFieldIT { SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, FieldTypeDescriptor.getAll() ) ) .name( "nesting_missingField" ); - public InObjectFieldIT() { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, ObjectFieldBinding objectFieldBinding, - int matchingDocOrdinal) { - return f.id().matching( dataSet.docId( matchingDocOrdinal ) ); + int matchingDocOrdinal, AbstractPredicateDataSet dataSet) { + return f.id().matching( InObjectFieldIT.dataSet.docId( matchingDocOrdinal ) ); } private static class DataSet extends AbstractPredicateDataSet { @@ -91,35 +89,39 @@ public void contribute(BulkIndexer mainIndexer, BulkIndexer missingFieldIndexer) } @Nested - public static class ScoreIT extends AbstractPredicateScoreIT { + class ScoreIT extends AbstractPredicateScoreIT { private static final DataSet dataSet = new DataSet(); private static final StubMappedIndex index = StubMappedIndex.withoutFields().name( "score" ); - public ScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.id().matching( dataSet.docId( matchingDocOrdinal ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { - return f.id().matching( dataSet.docId( matchingDocOrdinal ) ).boost( boost ); + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ).boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.id().matching( dataSet.docId( matchingDocOrdinal ) ).constantScore(); + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { - return f.id().matching( dataSet.docId( matchingDocOrdinal ) ).constantScore().boost( boost ); + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ).constantScore().boost( boost ); } private static class DataSet extends AbstractPredicateDataSet { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateConverterIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateConverterIT.java index ebddfcc020b..562b75473b7 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateConverterIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateConverterIT.java @@ -10,12 +10,12 @@ import java.util.Arrays; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test the DSL when the id of the entity is stored as a different type. @@ -24,34 +24,34 @@ * as a string with the prefix `document`. In the DSL the user will still use the integer type when * looking for entities matching an id. */ -public class MatchIdPredicateConverterIT { +class MatchIdPredicateConverterIT { private static final String DOCUMENT_1 = "document1"; private static final String DOCUMENT_2 = "document2"; private static final String DOCUMENT_3 = "document3"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final StubMappedIndex index = StubMappedIndex.ofAdvancedNonRetrievable( ctx -> ctx .idDslConverter( Integer.class, (value, context) -> "document" + value ) ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void match_id() { + void match_id() { assertThatQuery( index.query() .where( f -> f.id().matching( 1 ) ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); } @Test - public void match_multiple_ids() { + void match_multiple_ids() { assertThatQuery( index.query() .where( f -> f.id() .matching( 1 ) @@ -60,7 +60,7 @@ public void match_multiple_ids() { } @Test - public void match_any_and_match_single_id() { + void match_any_and_match_single_id() { assertThatQuery( index.query() .where( f -> f.id() .matching( 2 ) @@ -69,7 +69,7 @@ public void match_any_and_match_single_id() { } @Test - public void match_any_single_id() { + void match_any_single_id() { assertThatQuery( index.query() .where( f -> f.id() .matchingAny( Arrays.asList( 1 ) ) ) ) @@ -77,7 +77,7 @@ public void match_any_single_id() { } @Test - public void match_any_ids() { + void match_any_ids() { assertThatQuery( index.query() .where( f -> f.id() .matchingAny( Arrays.asList( 1, 3 ) ) ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateSpecificsIT.java index 9ea2bc576c6..2e196354815 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchIdPredicateSpecificsIT.java @@ -18,18 +18,18 @@ import org.hibernate.search.engine.reporting.spi.EventContexts; import org.hibernate.search.engine.search.common.ValueConvert; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MatchIdPredicateSpecificsIT { +class MatchIdPredicateSpecificsIT { // it should be more than the default max clause count of the boolean queries private static final int LOT_OF_TERMS_SIZE = 2000; @@ -40,8 +40,8 @@ public class MatchIdPredicateSpecificsIT { private static final String COMPATIBLE_ID_CONVERTER_DOCUMENT_1 = "compatibleIdConverter_document1"; private static final String INCOMPATIBLE_ID_CONVERTER_DOCUMENT_1 = "incompatibleIdConverter_document1"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final StubMappedIndex mainIndex = StubMappedIndex.withoutFields().name( "main" ); @@ -55,8 +55,8 @@ public class MatchIdPredicateSpecificsIT { // only one of which is matching private static final List lotsOfTerms = new ArrayList<>(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( mainIndex, compatibleIdConverterIndex, incompatibleIdConverterIndex ).setup(); for ( int i = 1; i <= LOT_OF_TERMS_SIZE; i++ ) { @@ -70,14 +70,14 @@ public static void setup() { } @Test - public void matching() { + void matching() { assertThatQuery( mainIndex.query() .where( f -> f.id().matching( DOCUMENT_1 ) ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), DOCUMENT_1 ); } @Test - public void matching_then_matching() { + void matching_then_matching() { assertThatQuery( mainIndex.query() .where( f -> f.id() .matching( DOCUMENT_1 ) @@ -86,7 +86,7 @@ public void matching_then_matching() { } @Test - public void matching_then_matchingAny() { + void matching_then_matchingAny() { assertThatQuery( mainIndex.query() .where( f -> f.id() .matching( DOCUMENT_2 ) @@ -95,7 +95,7 @@ public void matching_then_matchingAny() { } @Test - public void matchingAny_singleElement() { + void matchingAny_singleElement() { assertThatQuery( mainIndex.query() .where( f -> f.id() .matchingAny( Arrays.asList( DOCUMENT_1 ) ) ) ) @@ -103,7 +103,7 @@ public void matchingAny_singleElement() { } @Test - public void matchingAny_multipleElements() { + void matchingAny_multipleElements() { assertThatQuery( mainIndex.query() .where( f -> f.id() .matchingAny( Arrays.asList( DOCUMENT_1, DOCUMENT_3 ) ) ) ) @@ -111,7 +111,7 @@ public void matchingAny_multipleElements() { } @Test - public void matchingAny_lotsOfTerms() { + void matchingAny_lotsOfTerms() { assertThatQuery( mainIndex.query() .where( f -> f.id() .matchingAny( lotsOfTerms ) ) ) @@ -119,7 +119,7 @@ public void matchingAny_lotsOfTerms() { } @Test - public void multiIndex_withCompatibleIdConverterIndexManager_dslConverterEnabled() { + void multiIndex_withCompatibleIdConverterIndexManager_dslConverterEnabled() { StubMappingScope scope = mainIndex.createScope( compatibleIdConverterIndex ); assertThatQuery( scope.query() @@ -131,7 +131,7 @@ public void multiIndex_withCompatibleIdConverterIndexManager_dslConverterEnabled } @Test - public void multiIndex_withIncompatibleIdConverterIndex_dslConverterEnabled() { + void multiIndex_withIncompatibleIdConverterIndex_dslConverterEnabled() { SearchPredicateFactory f = mainIndex.createScope( incompatibleIdConverterIndex ).predicate(); assertThatThrownBy( () -> f.id().matching( new Object() /* Value does not matter */ ) ) @@ -146,7 +146,7 @@ public void multiIndex_withIncompatibleIdConverterIndex_dslConverterEnabled() { } @Test - public void multiIndex_withIncompatibleIdConverterIndex_dslConverterDisabled() { + void multiIndex_withIncompatibleIdConverterIndex_dslConverterDisabled() { StubMappingScope scope = mainIndex.createScope( incompatibleIdConverterIndex ); assertThatQuery( scope.query() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchNonePredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchNonePredicateSpecificsIT.java index 64ebf662864..1bb0a8e8204 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchNonePredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchNonePredicateSpecificsIT.java @@ -12,14 +12,14 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.types.dsl.IndexFieldTypeFactory; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MatchNonePredicateSpecificsIT { +class MatchNonePredicateSpecificsIT { private static final String DOCUMENT_1 = "1"; private static final String STRING_1 = "aaa"; @@ -30,27 +30,27 @@ public class MatchNonePredicateSpecificsIT { private static final String DOCUMENT_3 = "3"; private static final String STRING_3 = "ccc"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void matchNone() { + void matchNone() { assertThatQuery( index.query() .where( SearchPredicateFactory::matchNone ) ) .hasNoHits(); } @Test - public void matchNoneWithinBoolPredicate() { + void matchNoneWithinBoolPredicate() { //check that we will find something with a single match predicate assertThatQuery( index.query() .where( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchPredicateBaseIT.java index 57f4c5ad528..0a1d3233bea 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchPredicateBaseIT.java @@ -16,20 +16,19 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.InvalidType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class MatchPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class MatchPredicateBaseIT { + //CHECKSTYLE:ON private static final List> supportedFieldTypes = new ArrayList<>(); private static final List> unsupportedFieldTypes = new ArrayList<>(); @@ -44,11 +43,11 @@ public class MatchPredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -116,102 +115,76 @@ private static MatchPredicateTestValues testValues(FieldTypeDescriptor return new MatchPredicateTestValues<>( fieldType ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT> { + class SingleFieldIT extends AbstractPredicateSingleFieldIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "singleField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "singleField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public SingleFieldIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.match().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT> { + class MultiFieldIT extends AbstractPredicateMultiFieldIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "multiField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "multiField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public MultiFieldIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, DataSet> dataSet) { return f.match().field( fieldPath ).field( otherFieldPath ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override - protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal) { + protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal, + DataSet> dataSet) { return f.match().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, DataSet> dataSet) { return f.match().field( fieldPath ).fields( fieldPaths ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT> { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT> { private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "nesting" ); @@ -220,23 +193,29 @@ public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFie SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); + } } - public InObjectFieldIT(DataSet> dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.match().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - public static class AnalysisIT extends AbstractPredicateConfigurableAnalysisIT { + class AnalysisIT extends AbstractPredicateConfigurableAnalysisIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) @@ -269,81 +248,84 @@ protected PredicateFinalStep predicateWithSkipAnalysis(SearchPredicateFactory f, } @Nested - @RunWith(Parameterized.class) - public static class ScoreIT extends AbstractPredicateFieldScoreIT> { + class ScoreIT extends AbstractPredicateFieldScoreIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "score" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "score" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public ScoreIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { - return f.match().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { + return f.match().field( fieldPath ) + .matching( ( (DataSet>) dataSet ).values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { - return f.match().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) + int matchingDocOrdinal, DataSet> dataSet) { + return f.match().fields( fieldPaths ) + .matching( ( (DataSet>) dataSet ).values.matchingArg( matchingDocOrdinal ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { - return f.match().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) + int matchingDocOrdinal, float predicateBoost, DataSet> dataSet) { + return f.match().fields( fieldPaths ) + .matching( ( (DataSet>) dataSet ).values.matchingArg( matchingDocOrdinal ) ) .boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { - return f.match().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet> dataSet) { + return f.match().fields( fieldPaths ) + .matching( ( (DataSet>) dataSet ).values.matchingArg( matchingDocOrdinal ) ) .constantScore().boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet> dataSet) { return f.match().field( fieldPath ).boost( fieldBoost ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .matching( ( (DataSet>) dataSet ).values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, DataSet> dataSet) { return f.match().field( fieldPath ).boost( fieldBoost ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); + .matching( ( (DataSet>) dataSet ).values.matchingArg( matchingDocOrdinal ) ) + .constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet> dataSet) { return f.match().field( fieldPath ).boost( fieldBoost ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); + .matching( ( (DataSet>) dataSet ).values.matchingArg( matchingDocOrdinal ) ) + .boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -363,26 +345,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) .name( "unsupportedType" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -397,15 +373,7 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class SearchableIT extends AbstractPredicateSearchableIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -414,13 +382,15 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( searchableYesIndex, searchableNoIndex, fieldType ) ); + } } - public SearchableIT(FieldTypeDescriptor fieldType) { - super( searchableYesIndex, searchableNoIndex, fieldType ); + public static List params() { + return parameters; } @Override @@ -435,26 +405,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "argumentChecking" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public ArgumentCheckingIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -464,19 +428,8 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - @RunWith(Parameterized.class) - public static class TypeCheckingAndConversionIT + class TypeCheckingAndConversionIT extends AbstractPredicateTypeCheckingAndConversionIT, Object> { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_main" ); @@ -493,13 +446,19 @@ public static class TypeCheckingAndConversionIT SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, + incompatibleIndex, dataSet ) ); + } } - public TypeCheckingAndConversionIT(DataSet> dataSet) { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + public static List params() { + return parameters; } @Override @@ -525,12 +484,12 @@ protected Object invalidTypeParam() { } @Override - protected Object unwrappedMatchingParam(int matchingDocOrdinal) { + protected Object unwrappedMatchingParam(int matchingDocOrdinal, DataSet> dataSet) { return dataSet.values.matchingArg( matchingDocOrdinal ); } @Override - protected Object wrappedMatchingParam(int matchingDocOrdinal) { + protected Object wrappedMatchingParam(int matchingDocOrdinal, DataSet> dataSet) { return new ValueWrapper<>( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @@ -541,7 +500,7 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class ScaleCheckingIT extends AbstractPredicateScaleCheckingIT { + class ScaleCheckingIT extends AbstractPredicateScaleCheckingIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchPredicateFuzzyIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchPredicateFuzzyIT.java index 1e2984240cc..c78c89b6208 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchPredicateFuzzyIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/MatchPredicateFuzzyIT.java @@ -27,7 +27,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.NormalizedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.CollectionHelper; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; @@ -35,11 +35,11 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MatchPredicateFuzzyIT { +class MatchPredicateFuzzyIT { private static final List> unsupportedFieldTypes = FieldTypeDescriptor.getAll().stream() .filter( fieldType -> !String.class.equals( fieldType.getJavaType() ) @@ -47,15 +47,15 @@ public class MatchPredicateFuzzyIT { && !GeoPointFieldTypeDescriptor.INSTANCE.equals( fieldType ) ) .collect( Collectors.toList() ); - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private static final DataSet dataSet = new DataSet(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer bulkIndexer = index.bulkIndexer(); @@ -65,7 +65,7 @@ public static void setup() { @Test @PortedFromSearch5(original = "org.hibernate.search.test.dsl.DSLTest.testFuzzyQuery") - public void fuzzy() { + void fuzzy() { String absoluteFieldPath = index.binding().analyzedStringField.relativeFieldName; Function> createQuery = text -> index.query() .where( f -> f.match() @@ -86,7 +86,7 @@ public void fuzzy() { @Test @PortedFromSearch5(original = "org.hibernate.search.test.dsl.DSLTest.testFuzzyQuery") - public void maxEditDistance() { + void maxEditDistance() { String absoluteFieldPath = index.binding().analyzedStringField.relativeFieldName; BiFunction> createQuery = (text, maxEditDistance) -> index.query() @@ -128,7 +128,7 @@ public void maxEditDistance() { @Test @PortedFromSearch5(original = "org.hibernate.search.test.dsl.DSLTest.testFuzzyQuery") - public void exactPrefixLength() { + void exactPrefixLength() { String absoluteFieldPath = index.binding().analyzedStringField.relativeFieldName; BiFunction> createQuery = (text, exactPrefixLength) -> index.query() @@ -169,7 +169,7 @@ public void exactPrefixLength() { } @Test - public void normalizedStringField() { + void normalizedStringField() { String absoluteFieldPath = index.binding().normalizedStringField.relativeFieldName; Function> createQuery; @@ -199,7 +199,7 @@ public void normalizedStringField() { @Test @PortedFromSearch5(original = "org.hibernate.search.test.dsl.DSLTest.testFuzzyQueryOnMultipleFields") - public void multipleFields() { + void multipleFields() { String absoluteFieldPath1 = index.binding().analyzedStringField.relativeFieldName; String absoluteFieldPath2 = index.binding().analyzedString2Field.relativeFieldName; Function> createQuery; @@ -218,7 +218,7 @@ public void multipleFields() { } @Test - public void unsupportedFieldType() { + void unsupportedFieldType() { SearchPredicateFactory f = index.createScope().predicate(); for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { @@ -256,7 +256,7 @@ public void unsupportedFieldType() { } @Test - public void invalidMaxEditDistance() { + void invalidMaxEditDistance() { SearchPredicateFactory f = index.createScope().predicate(); String absoluteFieldPath = index.binding().analyzedStringField.relativeFieldName; @@ -274,7 +274,7 @@ public void invalidMaxEditDistance() { } @Test - public void invalidPrefixLength() { + void invalidPrefixLength() { SearchPredicateFactory f = index.createScope().predicate(); String absoluteFieldPath = index.binding().analyzedStringField.relativeFieldName; @@ -286,7 +286,7 @@ public void invalidPrefixLength() { } @Test - public void analyzerOverride() { + void analyzerOverride() { String whitespaceAnalyzedField = index.binding().whitespaceAnalyzedField.relativeFieldName; String whitespaceLowercaseAnalyzedField = index.binding().whitespaceLowercaseAnalyzedField.relativeFieldName; String whitespaceLowercaseSearchAnalyzedField = @@ -323,7 +323,7 @@ public void analyzerOverride() { } @Test - public void skipAnalysis() { + void skipAnalysis() { String absoluteFieldPath = index.binding().whitespaceLowercaseAnalyzedField.relativeFieldName; assertThatQuery( index.query() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NamedPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NamedPredicateBaseIT.java index 91aee190063..c4111828214 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NamedPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NamedPredicateBaseIT.java @@ -20,16 +20,16 @@ import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class NamedPredicateBaseIT { +class NamedPredicateBaseIT { private static final String DOCUMENT_1 = "document1"; private static final String DOCUMENT_2 = "document2"; @@ -41,15 +41,15 @@ public class NamedPredicateBaseIT { private static final String WORD_4 = "word4"; private static final String WORD_5 = "word5"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private static final DataSet dataSet = new DataSet(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -58,7 +58,7 @@ public static void setup() { } @Test - public void root() { + void root() { assertThatQuery( index.query() .where( f -> f.named( "match-both-fields" ) .param( "value1", WORD_1 ) @@ -72,7 +72,7 @@ public void root() { } @Test - public void nested() { + void nested() { assertThatQuery( index.query() .where( f -> f.named( "nested.match-both-fields" ) .param( "value1", WORD_1 ) @@ -92,7 +92,7 @@ public void nested() { } @Test - public void flattened() { + void flattened() { assertThatQuery( index.query() .where( f -> f.named( "flattened.match-both-fields" ) .param( "value1", WORD_1 ) @@ -111,7 +111,7 @@ public void flattened() { } @Test - public void nullPath() { + void nullPath() { SearchPredicateFactory f = index.createScope().predicate(); assertThatThrownBy( () -> f.named( null ) ) .isInstanceOf( IllegalArgumentException.class ) @@ -119,7 +119,7 @@ public void nullPath() { } @Test - public void unknownField() { + void unknownField() { SearchPredicateFactory f = index.createScope().predicate(); assertThatThrownBy( () -> f.named( "unknown_field.my-predicate" ) ) .isInstanceOf( SearchException.class ) @@ -127,7 +127,7 @@ public void unknownField() { } @Test - public void unknownPredicate_root() { + void unknownPredicate_root() { SearchPredicateFactory f = index.createScope().predicate(); assertThatThrownBy( () -> f.named( "unknown-predicate" ) ) .isInstanceOf( SearchException.class ) @@ -135,7 +135,7 @@ public void unknownPredicate_root() { } @Test - public void unknownPredicate_objectField() { + void unknownPredicate_objectField() { SearchPredicateFactory f = index.createScope().predicate(); assertThatThrownBy( () -> f.named( "nested.unknown-predicate" ) ) .isInstanceOf( SearchException.class ) @@ -143,7 +143,7 @@ public void unknownPredicate_objectField() { } @Test - public void unknownPredicate_valueField() { + void unknownPredicate_valueField() { SearchPredicateFactory f = index.createScope().predicate(); assertThatThrownBy( () -> f.named( "field1.unknown-predicate" ) ) .isInstanceOf( SearchException.class ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NamedPredicateMultiIndexCompatibilityIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NamedPredicateMultiIndexCompatibilityIT.java index 467fcfcae55..a1760e678b8 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NamedPredicateMultiIndexCompatibilityIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NamedPredicateMultiIndexCompatibilityIT.java @@ -18,7 +18,7 @@ import org.hibernate.search.engine.search.predicate.definition.PredicateDefinitionContext; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; @@ -26,14 +26,14 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class NamedPredicateMultiIndexCompatibilityIT { +class NamedPredicateMultiIndexCompatibilityIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -45,8 +45,8 @@ public class NamedPredicateMultiIndexCompatibilityIT { SimpleMappedIndex.of( IncompatibleIndexBinding::new ).name( "incompatible" ); protected static final DataSet dataSet = new DataSet(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( index, compatibleIndex, missingPredicateIndex, incompatibleIndex ) .setup(); @@ -59,7 +59,7 @@ public static void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-4166") - public void multiIndex_withCompatibleIndex() { + void multiIndex_withCompatibleIndex() { StubMappingScope scope = index.createScope( compatibleIndex ); assertThatQuery( scope.query() @@ -72,7 +72,7 @@ public void multiIndex_withCompatibleIndex() { @Test @TestForIssue(jiraKey = "HSEARCH-4166") - public void multiIndex_withMissingPredicateIndex() { + void multiIndex_withMissingPredicateIndex() { StubMappingScope scope = index.createScope( missingPredicateIndex ); assertThatThrownBy( () -> scope.predicate().named( "my-predicate" ) ) @@ -89,7 +89,7 @@ public void multiIndex_withMissingPredicateIndex() { @Test @TestForIssue(jiraKey = "HSEARCH-4166") - public void multiIndex_withIncompatibleIndex() { + void multiIndex_withIncompatibleIndex() { StubMappingScope scope = index.createScope( incompatibleIndex ); assertThatThrownBy( () -> scope.predicate().named( "my-predicate" ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NestedPredicateLegacyIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NestedPredicateLegacyIT.java index 03490f086df..fa451dadd21 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NestedPredicateLegacyIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NestedPredicateLegacyIT.java @@ -17,22 +17,22 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.search.predicate.SearchPredicate; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests for the legacy syntax of nested predicate definition. */ @SuppressWarnings("deprecation") -public class NestedPredicateLegacyIT { +class NestedPredicateLegacyIT { private static final String DOCUMENT_1 = "nestedQueryShouldMatchId"; private static final String DOCUMENT_2 = "nonNestedQueryShouldMatchId"; @@ -51,22 +51,22 @@ public class NestedPredicateLegacyIT { private static final String NON_MATCHING_SECOND_LEVEL_CONDITION2_FIELD1 = "secondNonMatchingWord"; private static final String NON_MATCHING_SECOND_LEVEL_CONDITION2_FIELD2 = "secondNonMatchingWord"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ); private static final SimpleMappedIndex missingFieldIndex = SimpleMappedIndex.of( MissingFieldIndexBinding::new ).name( "missingField" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( mainIndex, missingFieldIndex ).setup(); initData(); } @Test - public void search_nestedOnTwoLevels() { + void search_nestedOnTwoLevels() { assertThatQuery( mainIndex.query() .where( f -> f.nested().objectField( "nestedObject" ) .nest( f.and( @@ -97,7 +97,7 @@ public void search_nestedOnTwoLevels() { } @Test - public void search_nestedOnTwoLevels_onlySecondLevel() { + void search_nestedOnTwoLevels_onlySecondLevel() { assertThatQuery( mainIndex.query() .where( f -> f.and( // This is referred to as "condition 1" in the data initialization method @@ -126,7 +126,7 @@ public void search_nestedOnTwoLevels_onlySecondLevel() { } @Test - public void search_nestedOnTwoLevels_conditionOnFirstLevel() { + void search_nestedOnTwoLevels_conditionOnFirstLevel() { assertThatQuery( mainIndex.query() .where( f -> f.nested().objectField( "nestedObject" ) .nest( f.and( @@ -150,7 +150,7 @@ public void search_nestedOnTwoLevels_conditionOnFirstLevel() { } @Test - public void search_nestedOnTwoLevels_separatePredicates() { + void search_nestedOnTwoLevels_separatePredicates() { StubMappingScope scope = mainIndex.createScope(); SearchPredicate predicate1 = scope.predicate().nested().objectField( "nestedObject.nestedObject" ) @@ -189,7 +189,7 @@ public void search_nestedOnTwoLevels_separatePredicates() { } @Test - public void invalidNestedPath_parent() { + void invalidNestedPath_parent() { String objectFieldPath = "nestedObject"; String fieldInParentPath = "string"; @@ -213,7 +213,7 @@ public void invalidNestedPath_parent() { } @Test - public void invalidNestedPath_sibling() { + void invalidNestedPath_sibling() { String objectFieldPath = "nestedObject"; String fieldInSiblingPath = "nestedObject2.string"; @@ -242,7 +242,7 @@ public void invalidNestedPath_sibling() { */ @Test @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_missingNestedField() { + void multiIndex_missingNestedField() { StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); SearchPredicateFactory f = scope.predicate(); SearchPredicate nestedPredicate = f.nested().objectField( "nestedObject" ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NestedPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NestedPredicateSpecificsIT.java index d76980d0ddd..c0c440eb906 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NestedPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NestedPredicateSpecificsIT.java @@ -17,18 +17,18 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.search.predicate.SearchPredicate; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class NestedPredicateSpecificsIT { +class NestedPredicateSpecificsIT { private static final String DOCUMENT_1 = "nestedQueryShouldMatchId"; private static final String DOCUMENT_2 = "nonNestedQueryShouldMatchId"; @@ -47,22 +47,22 @@ public class NestedPredicateSpecificsIT { private static final String NON_MATCHING_SECOND_LEVEL_CONDITION2_FIELD1 = "secondNonMatchingWord"; private static final String NON_MATCHING_SECOND_LEVEL_CONDITION2_FIELD2 = "secondNonMatchingWord"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ); private static final SimpleMappedIndex missingFieldIndex = SimpleMappedIndex.of( MissingFieldIndexBinding::new ).name( "missingField" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( mainIndex, missingFieldIndex ).setup(); initData(); } @Test - public void search_nestedOnTwoLevels() { + void search_nestedOnTwoLevels() { assertThatQuery( mainIndex.query() .where( f -> f.nested( "nestedObject" ) // This is referred to as "condition 1" in the data initialization method @@ -93,7 +93,7 @@ public void search_nestedOnTwoLevels() { } @Test - public void search_nestedOnTwoLevels_onlySecondLevel() { + void search_nestedOnTwoLevels_onlySecondLevel() { assertThatQuery( mainIndex.query() .where( (f, root) -> root // This is referred to as "condition 1" in the data initialization method @@ -124,7 +124,7 @@ public void search_nestedOnTwoLevels_onlySecondLevel() { } @Test - public void with() { + void with() { assertThatQuery( mainIndex.query() .where( (f, root) -> root // This is referred to as "condition 1" in the data initialization method @@ -159,7 +159,7 @@ public void with() { } @Test - public void search_nestedOnTwoLevels_conditionOnFirstLevel() { + void search_nestedOnTwoLevels_conditionOnFirstLevel() { assertThatQuery( mainIndex.query() .where( f -> f.nested( "nestedObject" ) .add( f.match() @@ -183,7 +183,7 @@ public void search_nestedOnTwoLevels_conditionOnFirstLevel() { } @Test - public void search_nestedOnTwoLevels_separatePredicates() { + void search_nestedOnTwoLevels_separatePredicates() { StubMappingScope scope = mainIndex.createScope(); SearchPredicate predicate1 = scope.predicate().nested( "nestedObject.nestedObject" ) @@ -216,7 +216,7 @@ public void search_nestedOnTwoLevels_separatePredicates() { } @Test - public void invalidNestedPath_parent() { + void invalidNestedPath_parent() { String objectFieldPath = "nestedObject"; String fieldInParentPath = "string"; @@ -240,7 +240,7 @@ public void invalidNestedPath_parent() { } @Test - public void invalidNestedPath_sibling() { + void invalidNestedPath_sibling() { String objectFieldPath = "nestedObject"; String fieldInSiblingPath = "nestedObject2.string"; @@ -269,7 +269,7 @@ public void invalidNestedPath_sibling() { */ @Test @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_missingNestedField() { + void multiIndex_missingNestedField() { StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); SearchPredicateFactory f = scope.predicate(); SearchPredicate nestedPredicate = f.nested( "nestedObject" ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NotPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NotPredicateBaseIT.java index caad31820ae..ee244bc0016 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NotPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NotPredicateBaseIT.java @@ -13,25 +13,25 @@ import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class NotPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class NotPredicateBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( ScoreIT.index @@ -44,43 +44,40 @@ public static void setup() { scoreIndexer.join(); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class ScoreIT extends AbstractPredicateScoreIT { + class ScoreIT extends AbstractPredicateScoreIT { private static final DataSet dataSet = new DataSet(); private static final StubMappedIndex index = StubMappedIndex.withoutFields().name( "score" ); - public ScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.not( f.id().matchingAny( dataSet.docsExcept( matchingDocOrdinal ) ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.not( f.id().matchingAny( ( (DataSet) dataSet ).docsExcept( matchingDocOrdinal ) ) ); } @Override - protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { - return f.not( f.id().matchingAny( dataSet.docsExcept( matchingDocOrdinal ) ) ) + protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, float boost, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.not( f.id().matchingAny( ( (DataSet) dataSet ).docsExcept( matchingDocOrdinal ) ) ) .boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.not( f.id().matchingAny( dataSet.docsExcept( matchingDocOrdinal ) ) ) + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.not( f.id().matchingAny( ( (DataSet) dataSet ).docsExcept( matchingDocOrdinal ) ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { - return f.not( f.id().matchingAny( dataSet.docsExcept( matchingDocOrdinal ) ) ) + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.not( f.id().matchingAny( ( (DataSet) dataSet ).docsExcept( matchingDocOrdinal ) ) ) .constantScore() .boost( boost ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NotPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NotPredicateSpecificsIT.java index 2fc5e5ebf13..def96407d70 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NotPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/NotPredicateSpecificsIT.java @@ -11,15 +11,15 @@ import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class NotPredicateSpecificsIT { +class NotPredicateSpecificsIT { private static final String DOCUMENT_1 = "1"; private static final String DOCUMENT_2 = "2"; @@ -49,27 +49,27 @@ public class NotPredicateSpecificsIT { private static final Integer FIELD4_VALUE3 = 42_000; // Different from document 1 private static final Integer FIELD5_VALUE3 = 142_000; // Different from document 1 - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void notMatchAll() { + void notMatchAll() { assertThatQuery( index.query() .where( f -> f.not( f.matchAll() ) ) ) .hasNoHits(); } @Test - public void notMatchNone() { + void notMatchNone() { assertThatQuery( index.query() .where( f -> f.not( f.matchNone() ) ) ) .hasTotalHitCount( 3 ) @@ -77,7 +77,7 @@ public void notMatchNone() { } @Test - public void notMatchSpecificValue() { + void notMatchSpecificValue() { assertThatQuery( index.query() .where( f -> f.not( f.match().field( "field2" ).matching( FIELD2_VALUE1 ) ) ) ) .hasTotalHitCount( 2 ) @@ -85,7 +85,7 @@ public void notMatchSpecificValue() { } @Test - public void mustWithNotInside() { + void mustWithNotInside() { assertThatQuery( index.query() .where( f -> f.bool().must( f.not( f.match().field( "field2" ).matching( FIELD2_VALUE1 ) ) ) ) ) .hasTotalHitCount( 2 ) @@ -93,7 +93,7 @@ public void mustWithNotInside() { } @Test - public void manyNestedNot() { + void manyNestedNot() { SearchPredicateFactory f = index.createScope().predicate(); assertThatQuery( index.query() @@ -115,7 +115,7 @@ public void manyNestedNot() { } @Test - public void combinationOfMustMustNotAndNestedNot() { + void combinationOfMustMustNotAndNestedNot() { assertThatQuery( index.query() .where( f -> f.bool() .must( f.match().field( "field2" ).matching( FIELD2_VALUE1 ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/OrPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/OrPredicateBaseIT.java index 859287b5a60..38f8419c3fb 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/OrPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/OrPredicateBaseIT.java @@ -6,27 +6,30 @@ */ package org.hibernate.search.integrationtest.backend.tck.search.predicate; +import java.util.Arrays; +import java.util.List; + import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class OrPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class OrPredicateBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( ScoreIT.index, @@ -44,43 +47,42 @@ public static void setup() { addScoreIndexer.join(); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class ScoreIT extends AbstractPredicateScoreIT { + class ScoreIT extends AbstractPredicateScoreIT { private static final DataSet dataSet = new DataSet(); private static final StubMappedIndex index = StubMappedIndex.withoutFields().name( "score" ); - public ScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.or( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.or( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ); } @Override protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { - return f.or( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.or( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { - return f.or( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { + return f.or( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { - return f.or( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { + return f.or( f.id().matching( ScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore() .boost( boost ); } @@ -99,41 +101,45 @@ public void contribute(BulkIndexer scoreIndexer) { } @Nested - public static class AddScoreIT extends AbstractPredicateScoreIT { + class AddScoreIT extends AbstractPredicateScoreIT { private static final DataSet dataSet = new DataSet(); private static final StubMappedIndex index = StubMappedIndex.withoutFields().name( "addscore" ); - public AddScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { return f.or() - .add( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ); + .add( f.id().matching( AddScoreIT.dataSet.docId( matchingDocOrdinal ) ) ); } @Override protected PredicateFinalStep predicateWithBoost(SearchPredicateFactory f, int matchingDocOrdinal, - float boost) { + float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { return f.or() - .add( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + .add( f.id().matching( AddScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .boost( boost ); } @Override - protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal) { + protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, int matchingDocOrdinal, + AbstractPredicateDataSet dataSet, StubMappedIndex index) { return f.or() - .add( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + .add( f.id().matching( AddScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithConstantScoreAndBoost(SearchPredicateFactory f, - int matchingDocOrdinal, float boost) { + int matchingDocOrdinal, float boost, AbstractPredicateDataSet dataSet, + StubMappedIndex index) { return f.or() - .add( f.id().matching( dataSet.docId( matchingDocOrdinal ) ) ) + .add( f.id().matching( AddScoreIT.dataSet.docId( matchingDocOrdinal ) ) ) .constantScore() .boost( boost ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/OrPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/OrPredicateSpecificsIT.java index be6d961681d..ebe25a17720 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/OrPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/OrPredicateSpecificsIT.java @@ -13,16 +13,16 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.types.dsl.IndexFieldTypeFactory; import org.hibernate.search.engine.search.predicate.SearchPredicate; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class OrPredicateSpecificsIT { +class OrPredicateSpecificsIT { private static final String DOCUMENT_1 = "1"; private static final String DOCUMENT_2 = "2"; @@ -52,27 +52,27 @@ public class OrPredicateSpecificsIT { private static final Integer FIELD4_VALUE3 = 42_000; // Different from document 1 private static final Integer FIELD5_VALUE3 = 142_000; // Different from document 1 - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void empty() { + void empty() { assertThatQuery( index.query() .where( f -> f.or() ) ) .hasNoHits(); } @Test - public void or() { + void or() { assertThatQuery( index.query() .where( f -> f.or( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOCUMENT_1 ); @@ -86,7 +86,7 @@ public void or() { } @Test - public void or_separatePredicateObject() { + void or_separatePredicateObject() { StubMappingScope scope = index.createScope(); SearchPredicate predicate1 = scope.predicate().match().field( "field1" ).matching( FIELD1_VALUE1 ) @@ -104,7 +104,7 @@ public void or_separatePredicateObject() { } @Test - public void nested() { + void nested() { assertThatQuery( index.query() .where( f -> f.or( f.and( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ), @@ -114,7 +114,7 @@ public void nested() { } @Test - public void add() { + void add() { assertThatQuery( index.query() .where( f -> f.or() .add( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) ) ) @@ -128,7 +128,7 @@ public void add() { } @Test - public void add_separatePredicateObject() { + void add_separatePredicateObject() { StubMappingScope scope = index.createScope(); SearchPredicate predicate1 = scope.predicate().match().field( "field1" ).matching( FIELD1_VALUE1 ) @@ -149,7 +149,7 @@ public void add_separatePredicateObject() { } @Test - public void add_function() { + void add_function() { assertThatQuery( index.query() .where( f -> f.or() .add( f2 -> f2.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) ) ) @@ -163,7 +163,7 @@ public void add_function() { } @Test - public void with() { + void with() { assertThatQuery( index.query() .where( f -> f.or() .with( or -> or.add( f.match().field( "field1" ).matching( FIELD1_VALUE1 ) ) ) ) ) @@ -177,7 +177,7 @@ public void with() { } @Test - public void hasClause() { + void hasClause() { StubMappingScope scope = index.createScope(); assertThat( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PhrasePredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PhrasePredicateBaseIT.java index ab104ff0651..73acf574659 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PhrasePredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PhrasePredicateBaseIT.java @@ -14,22 +14,22 @@ import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.AssumptionViolatedException; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(NestedRunner.class) -public class PhrasePredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class PhrasePredicateBaseIT { + //CHECKSTYLE:ON private static final List> supportedFieldTypes = new ArrayList<>(); private static final List> unsupportedFieldTypes = new ArrayList<>(); @@ -46,11 +46,11 @@ public class PhrasePredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -111,102 +111,76 @@ private static PhrasePredicateTestValues testValues(FieldTypeDescriptor return new PhrasePredicateTestValues( fieldType ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT { + class SingleFieldIT extends AbstractPredicateSingleFieldIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "singleField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "singleField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public SingleFieldIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.phrase().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT { + class MultiFieldIT extends AbstractPredicateMultiFieldIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "multiField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "multiField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public MultiFieldIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, DataSet dataSet) { return f.phrase().field( fieldPath ).field( otherFieldPath ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override - protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal) { + protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal, + DataSet dataSet) { return f.phrase().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, DataSet dataSet) { return f.phrase().field( fieldPath ).fields( fieldPaths ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "nesting" ); @@ -215,23 +189,29 @@ public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldI SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); + } } - public InObjectFieldIT(DataSet dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.phrase().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - public static class AnalysisIT extends AbstractPredicateConfigurableAnalysisIT { + class AnalysisIT extends AbstractPredicateConfigurableAnalysisIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) @@ -247,13 +227,13 @@ public AnalysisIT() { @Override public void analyzerOverride_queryOnlyAnalyzer() { - throw new AssumptionViolatedException( + throw new org.opentest4j.TestAbortedException( "Skipping this test as ngram analyzers don't work well together with phrase predicates" ); } @Override public void analyzerOverride_normalizedStringField() { - throw new AssumptionViolatedException( + throw new org.opentest4j.TestAbortedException( "Skipping this test as running an actual phrase query (with multiple tokens) will always fail on normalized fields" ); } @@ -276,81 +256,78 @@ protected PredicateFinalStep predicateWithSkipAnalysis(SearchPredicateFactory f, } @Nested - @RunWith(Parameterized.class) - public static class ScoreIT extends AbstractPredicateFieldScoreIT { + class ScoreIT extends AbstractPredicateFieldScoreIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "score" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "score" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public ScoreIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.phrase().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.phrase().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { + int matchingDocOrdinal, float predicateBoost, DataSet dataSet) { return f.phrase().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) .boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.phrase().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore().boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.phrase().field( fieldPath ).boost( fieldBoost ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.phrase().field( fieldPath ).boost( fieldBoost ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.phrase().field( fieldPath ).boost( fieldBoost ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -370,26 +347,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) .name( "unsupportedType" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -404,15 +375,7 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class SearchableIT extends AbstractPredicateSearchableIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -421,13 +384,15 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( searchableYesIndex, searchableNoIndex, fieldType ) ); + } } - public SearchableIT(FieldTypeDescriptor fieldType) { - super( searchableYesIndex, searchableNoIndex, fieldType ); + public static List params() { + return parameters; } @Override @@ -442,39 +407,34 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "argumentChecking" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public ArgumentCheckingIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } - @Test - public void invalidSlop() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void invalidSlop(SimpleMappedIndex index, FieldTypeDescriptor fieldType) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> f.phrase().field( fieldPath() ) + assertThatThrownBy( () -> f.phrase().field( fieldPath( index, fieldType ) ) .matching( "foo" ).slop( -1 ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Invalid slop" ) .hasMessageContaining( "must be positive or zero" ); - assertThatThrownBy( () -> f.phrase().field( fieldPath() ) + assertThatThrownBy( () -> f.phrase().field( fieldPath( index, fieldType ) ) .matching( "foo" ).slop( Integer.MIN_VALUE ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Invalid slop" ) @@ -488,24 +448,8 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - @RunWith(Parameterized.class) - public static class TypeCheckingNoConversionIT + class TypeCheckingNoConversionIT extends AbstractPredicateTypeCheckingNoConversionIT { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; - } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_main" ); @@ -522,18 +466,30 @@ public static List parameters() { SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - public TypeCheckingNoConversionIT(DataSet dataSet) { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, + incompatibleIndex, dataSet ) ); + } + } + + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.phrase().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, String field0Path, String field1Path, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.phrase().field( field0Path ).field( field1Path ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PhrasePredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PhrasePredicateSpecificsIT.java index c511ba8374b..33399785ccb 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PhrasePredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PhrasePredicateSpecificsIT.java @@ -17,16 +17,16 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.AnalyzedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class PhrasePredicateSpecificsIT { +class PhrasePredicateSpecificsIT { private static final String DOCUMENT_1 = "document1"; private static final String DOCUMENT_2 = "document2"; @@ -44,15 +44,15 @@ public class PhrasePredicateSpecificsIT { private static final String PHRASE_1_TEXT_SLOP_3_MATCH = "In the big house, the fox was quick."; private static final String PHRASE_1_TEXT_SLOP_NO_MATCH = "Completely unrelated phrase."; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private static final DataSet dataSet = new DataSet(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -62,7 +62,7 @@ public static void setup() { @Test @PortedFromSearch5(original = "org.hibernate.search.test.dsl.DSLTest.testPhraseQuery") - public void phrase() { + void phrase() { String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; assertThatQuery( index.query() @@ -71,7 +71,7 @@ public void phrase() { } @Test - public void nonAnalyzedField() { + void nonAnalyzedField() { String absoluteFieldPath = index.binding().nonAnalyzedField.relativeFieldName; assertThatQuery( index.query() @@ -85,7 +85,7 @@ public void nonAnalyzedField() { @Test @PortedFromSearch5(original = "org.hibernate.search.test.dsl.DSLTest.testPhraseQuery") - public void singleTerm() { + void singleTerm() { String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; assertThatQuery( index.query() @@ -95,7 +95,7 @@ public void singleTerm() { @Test @PortedFromSearch5(original = "org.hibernate.search.test.dsl.DSLTest.testPhraseQuery") - public void slop() { + void slop() { String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; Function> createQuery = slop -> index.query() .where( f -> f.phrase().field( absoluteFieldPath ).matching( PHRASE_1 ).slop( slop ) ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PredicateDefinitionContextIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PredicateDefinitionContextIT.java index c18a8ff53fc..c995833f5ba 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PredicateDefinitionContextIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/PredicateDefinitionContextIT.java @@ -21,26 +21,26 @@ import org.hibernate.search.engine.search.predicate.definition.PredicateDefinitionContext; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class PredicateDefinitionContextIT { +class PredicateDefinitionContextIT { private static final String DOCUMENT_1 = "document1"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -49,7 +49,7 @@ public static void setup() { } @Test - public void param() { + void param() { Object[] givenParams = new Object[] { "string", new Object(), 5L, Optional.empty() }; Object[] receivedParams = new Object[givenParams.length]; @@ -72,7 +72,7 @@ public void param() { } @Test - public void param_absent() { + void param_absent() { Object[] expectedParams = new Object[] { Optional.empty() }; Object[] actualParams = new Object[1]; @@ -88,7 +88,7 @@ public void param_absent() { } @Test - public void param_nullName() { + void param_nullName() { assertThatThrownBy( () -> index.createScope().predicate().named( "stub-predicate" ) .param( "impl", (PredicateDefinition) context -> { context.param( null, String.class ); @@ -100,7 +100,7 @@ public void param_nullName() { } @Test - public void missingParam() { + void missingParam() { assertThatThrownBy( () -> index.createScope().predicate().named( "stub-predicate" ) .param( "impl", (PredicateDefinition) context -> { context.param( "missing", String.class ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RangePredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RangePredicateBaseIT.java index 5c9592c177f..885c7ac0ac2 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RangePredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RangePredicateBaseIT.java @@ -18,22 +18,23 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.InvalidType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.data.Range; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(NestedRunner.class) -public class RangePredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class RangePredicateBaseIT { + //CHECKSTYLE:ON static final List> supportedFieldTypes = new ArrayList<>(); static final List> unsupportedFieldTypes = new ArrayList<>(); @@ -48,11 +49,11 @@ public class RangePredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -120,102 +121,76 @@ private static RangePredicateTestValues testValues(FieldTypeDescriptor return new RangePredicateTestValues<>( fieldType ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT> { + class SingleFieldIT extends AbstractPredicateSingleFieldIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "singleField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "singleField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public SingleFieldIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.range().field( fieldPath ).range( dataSet.values.matchingRange( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT> { + class MultiFieldIT extends AbstractPredicateMultiFieldIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "multiField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "multiField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public MultiFieldIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, DataSet> dataSet) { return f.range().field( fieldPath ).field( otherFieldPath ) .range( dataSet.values.matchingRange( matchingDocOrdinal ) ); } @Override - protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal) { + protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal, + DataSet> dataSet) { return f.range().fields( fieldPaths ).range( dataSet.values.matchingRange( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, DataSet> dataSet) { return f.range().field( fieldPath ).fields( fieldPaths ) .range( dataSet.values.matchingRange( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT> { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT> { private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "nesting" ); @@ -224,23 +199,29 @@ public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFie SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); + } } - public InObjectFieldIT(DataSet> dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.range().field( fieldPath ).range( dataSet.values.matchingRange( matchingDocOrdinal ) ); } } @Nested - public static class AnalysisIT extends AbstractPredicateSimpleAnalysisIT { + class AnalysisIT extends AbstractPredicateSimpleAnalysisIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) @@ -261,80 +242,77 @@ protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPat } @Nested - @RunWith(Parameterized.class) - public static class ScoreIT extends AbstractPredicateFieldScoreIT> { + class ScoreIT extends AbstractPredicateFieldScoreIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "score" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "score" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public ScoreIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.range().field( fieldPath ).range( dataSet.values.matchingRange( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet> dataSet) { return f.range().fields( fieldPaths ).range( dataSet.values.matchingRange( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { + int matchingDocOrdinal, float predicateBoost, DataSet> dataSet) { return f.range().fields( fieldPaths ).range( dataSet.values.matchingRange( matchingDocOrdinal ) ) .boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet> dataSet) { return f.range().fields( fieldPaths ).range( dataSet.values.matchingRange( matchingDocOrdinal ) ) .constantScore().boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet> dataSet) { return f.range().field( fieldPath ).boost( fieldBoost ) .range( dataSet.values.matchingRange( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, DataSet> dataSet) { return f.range().field( fieldPath ).boost( fieldBoost ) .range( dataSet.values.matchingRange( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet> dataSet) { return f.range().field( fieldPath ).boost( fieldBoost ) .range( dataSet.values.matchingRange( matchingDocOrdinal ) ).boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -354,26 +332,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) .name( "unsupportedType" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -388,15 +360,7 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class SearchableIT extends AbstractPredicateSearchableIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -405,13 +369,15 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( searchableYesIndex, searchableNoIndex, fieldType ) ); + } } - public SearchableIT(FieldTypeDescriptor fieldType) { - super( searchableYesIndex, searchableNoIndex, fieldType ); + public static List params() { + return parameters; } @Override @@ -426,39 +392,34 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "argumentChecking" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public ArgumentCheckingIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } - @Test - public void nullBounds() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void nullBounds(SimpleMappedIndex index, FieldTypeDescriptor fieldType) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> f.range().field( fieldPath() ) + assertThatThrownBy( () -> f.range().field( fieldPath( index, fieldType ) ) .range( Range.between( null, null ) ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid range", "at least one bound in range predicates must be non-null", - fieldPath() + fieldPath( index, fieldType ) ); } @@ -469,19 +430,8 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - @RunWith(Parameterized.class) - public static class TypeCheckingAndConversionIT + class TypeCheckingAndConversionIT extends AbstractPredicateTypeCheckingAndConversionIT, Range> { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_main" ); @@ -498,13 +448,19 @@ public static class TypeCheckingAndConversionIT SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, + incompatibleIndex, dataSet ) ); + } } - public TypeCheckingAndConversionIT(DataSet> dataSet) { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + public static List params() { + return parameters; } @Override @@ -530,13 +486,13 @@ protected Range invalidTypeParam() { } @Override - protected Range unwrappedMatchingParam(int matchingDocOrdinal) { + protected Range unwrappedMatchingParam(int matchingDocOrdinal, DataSet> dataSet) { return dataSet.values.matchingRange( matchingDocOrdinal ); } @Override - protected Range wrappedMatchingParam(int matchingDocOrdinal) { - return unwrappedMatchingParam( matchingDocOrdinal ).map( ValueWrapper::new ); + protected Range wrappedMatchingParam(int matchingDocOrdinal, DataSet> dataSet) { + return unwrappedMatchingParam( matchingDocOrdinal, dataSet ).map( ValueWrapper::new ); } @Override @@ -546,7 +502,7 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class ScaleCheckingIT extends AbstractPredicateScaleCheckingIT { + class ScaleCheckingIT extends AbstractPredicateScaleCheckingIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RangePredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RangePredicateSpecificsIT.java index 850d8d138c1..f002fbbac2e 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RangePredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RangePredicateSpecificsIT.java @@ -20,23 +20,22 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.data.RangeBoundInclusion; import org.hibernate.search.util.impl.integrationtest.common.assertion.NormalizedDocRefHit; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class RangePredicateSpecificsIT { +class RangePredicateSpecificsIT { private static final List> supportedFieldTypes = new ArrayList<>(); private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : FieldTypeDescriptor.getAll() ) { if ( !GeoPointFieldTypeDescriptor.INSTANCE.equals( fieldType ) @@ -48,22 +47,21 @@ public class RangePredicateSpecificsIT { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( new RangePredicateTestValues<>( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( dataSet ) ); } } - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer bulkIndexer = index.bulkIndexer(); @@ -71,218 +69,230 @@ public static void setup() { bulkIndexer.join(); } - private final DataSet dataSet; - - public RangePredicateSpecificsIT(DataSet dataSet) { - this.dataSet = dataSet; - } - - @Test - public void atLeast() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void atLeast(DataSet dataSet) { int docOrdinal = 1; assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .atLeast( value( docOrdinal ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( docOrdinal, null ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .atLeast( value( docOrdinal, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( docOrdinal, null, dataSet ) ); } - @Test - public void atLeast_withDslConverter_valueConvertDefault() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void atLeast_withDslConverter_valueConvertDefault(DataSet dataSet) { int docOrdinal = 1; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .atLeast( wrappedValue( docOrdinal ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( docOrdinal, null ) ); + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .atLeast( wrappedValue( docOrdinal, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( docOrdinal, null, dataSet ) ); } - @Test - public void atLeast_withDslConverter_valueConvertNo() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void atLeast_withDslConverter_valueConvertNo(DataSet dataSet) { int docOrdinal = 1; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .atLeast( value( docOrdinal ), ValueConvert.NO ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( docOrdinal, null ) ); + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .atLeast( value( docOrdinal, dataSet ), ValueConvert.NO ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( docOrdinal, null, dataSet ) ); } - @Test - public void greaterThan() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void greaterThan(DataSet dataSet) { int docOrdinal = 1; assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .greaterThan( value( docOrdinal ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( docOrdinal + 1, null ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .greaterThan( value( docOrdinal, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( docOrdinal + 1, null, dataSet ) ); } - @Test - public void greaterThan_withDslConverter_valueConvertDefault() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void greaterThan_withDslConverter_valueConvertDefault(DataSet dataSet) { int docOrdinal = 1; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .greaterThan( wrappedValue( docOrdinal ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( docOrdinal + 1, null ) ); + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .greaterThan( wrappedValue( docOrdinal, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( docOrdinal + 1, null, dataSet ) ); } - @Test - public void greaterThan_withDslConverter_valueConvertNo() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void greaterThan_withDslConverter_valueConvertNo(DataSet dataSet) { int docOrdinal = 1; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .greaterThan( value( docOrdinal ), ValueConvert.NO ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( docOrdinal + 1, null ) ); + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .greaterThan( value( docOrdinal, dataSet ), ValueConvert.NO ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( docOrdinal + 1, null, dataSet ) ); } - @Test - public void atMost() { - int docOrdinal = docCount() - 2; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void atMost(DataSet dataSet) { + int docOrdinal = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .atMost( value( docOrdinal ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .atMost( value( docOrdinal, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal, dataSet ) ); } - @Test - public void atMost_withDslConverter_valueConvertDefault() { - int docOrdinal = docCount() - 2; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void atMost_withDslConverter_valueConvertDefault(DataSet dataSet) { + int docOrdinal = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .atMost( wrappedValue( docOrdinal ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal ) ); + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .atMost( wrappedValue( docOrdinal, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal, dataSet ) ); } - @Test - public void atMost_withDslConverter_valueConvertNo() { - int docOrdinal = docCount() - 2; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void atMost_withDslConverter_valueConvertNo(DataSet dataSet) { + int docOrdinal = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .atMost( value( docOrdinal ), ValueConvert.NO ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal ) ); + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .atMost( value( docOrdinal, dataSet ), ValueConvert.NO ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal, dataSet ) ); } - @Test - public void lessThan() { - int docOrdinal = docCount() - 2; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void lessThan(DataSet dataSet) { + int docOrdinal = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .lessThan( value( docOrdinal ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal - 1 ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .lessThan( value( docOrdinal, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal - 1, dataSet ) ); } - @Test - public void lessThan_withDslConverter_valueConvertDefault() { - int docOrdinal = docCount() - 2; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void lessThan_withDslConverter_valueConvertDefault(DataSet dataSet) { + int docOrdinal = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .lessThan( wrappedValue( docOrdinal ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal - 1 ) ); + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .lessThan( wrappedValue( docOrdinal, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal - 1, dataSet ) ); } - @Test - public void lessThan_withDslConverter_valueConvertNo() { - int docOrdinal = docCount() - 2; + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void lessThan_withDslConverter_valueConvertNo(DataSet dataSet) { + int docOrdinal = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .lessThan( value( docOrdinal ), ValueConvert.NO ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal - 1 ) ); + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .lessThan( value( docOrdinal, dataSet ), ValueConvert.NO ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( null, docOrdinal - 1, dataSet ) ); } - @Test - public void between() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void between(DataSet dataSet) { int lowerValueNumber = 1; - int upperValueNumber = docCount() - 2; + int upperValueNumber = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .between( value( lowerValueNumber ), value( upperValueNumber ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .between( value( lowerValueNumber, dataSet ), value( upperValueNumber, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber, dataSet ) ); } - @Test - public void between_withDslConverter_valueConvertDefault() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void between_withDslConverter_valueConvertDefault(DataSet dataSet) { int lowerValueNumber = 1; - int upperValueNumber = docCount() - 2; + int upperValueNumber = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .between( wrappedValue( lowerValueNumber ), wrappedValue( upperValueNumber ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber ) ); + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .between( wrappedValue( lowerValueNumber, dataSet ), wrappedValue( upperValueNumber, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber, dataSet ) ); } - @Test - public void between_withDslConverter_valueConvertNo() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void between_withDslConverter_valueConvertNo(DataSet dataSet) { int lowerValueNumber = 1; - int upperValueNumber = docCount() - 2; + int upperValueNumber = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( customDslConverterFieldPath() ) - .between( value( lowerValueNumber ), value( upperValueNumber ), + .where( f -> f.range().field( customDslConverterFieldPath( dataSet ) ) + .between( value( lowerValueNumber, dataSet ), value( upperValueNumber, dataSet ), ValueConvert.NO ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber ) ); + .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber, dataSet ) ); } - @Test - public void between_boundInclusion() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void between_boundInclusion(DataSet dataSet) { int lowerValueNumber = 1; - int upperValueNumber = docCount() - 2; + int upperValueNumber = docCount( dataSet ) - 2; // Default is including both bounds assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .between( value( lowerValueNumber ), value( upperValueNumber ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .between( value( lowerValueNumber, dataSet ), value( upperValueNumber, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber, dataSet ) ); // explicit exclusion for the lower bound assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .between( value( lowerValueNumber ), RangeBoundInclusion.EXCLUDED, - value( upperValueNumber ), RangeBoundInclusion.INCLUDED ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber + 1, upperValueNumber ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .between( value( lowerValueNumber, dataSet ), RangeBoundInclusion.EXCLUDED, + value( upperValueNumber, dataSet ), RangeBoundInclusion.INCLUDED ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber + 1, upperValueNumber, dataSet ) ); // explicit exclusion for the upper bound assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .between( value( lowerValueNumber ), RangeBoundInclusion.INCLUDED, - value( upperValueNumber ), RangeBoundInclusion.EXCLUDED ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber - 1 ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .between( value( lowerValueNumber, dataSet ), RangeBoundInclusion.INCLUDED, + value( upperValueNumber, dataSet ), RangeBoundInclusion.EXCLUDED ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber - 1, dataSet ) ); // explicit inclusion for both bounds assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .between( value( lowerValueNumber ), RangeBoundInclusion.INCLUDED, - value( upperValueNumber ), RangeBoundInclusion.INCLUDED ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .between( value( lowerValueNumber, dataSet ), RangeBoundInclusion.INCLUDED, + value( upperValueNumber, dataSet ), RangeBoundInclusion.INCLUDED ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber, upperValueNumber, dataSet ) ); // explicit exclusion for both bounds assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .between( value( lowerValueNumber ), RangeBoundInclusion.EXCLUDED, - value( upperValueNumber ), RangeBoundInclusion.EXCLUDED ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber + 1, upperValueNumber - 1 ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .between( value( lowerValueNumber, dataSet ), RangeBoundInclusion.EXCLUDED, + value( upperValueNumber, dataSet ), RangeBoundInclusion.EXCLUDED ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( lowerValueNumber + 1, upperValueNumber - 1, dataSet ) ); } - @Test - public void between_nullBounds() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void between_nullBounds(DataSet dataSet) { int lowerDocOrdinal = 1; - int upperDocOrdinal = docCount() - 2; + int upperDocOrdinal = docCount( dataSet ) - 2; assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .between( value( lowerDocOrdinal ), null ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( lowerDocOrdinal, null ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .between( value( lowerDocOrdinal, dataSet ), null ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( lowerDocOrdinal, null, dataSet ) ); assertThatQuery( index.query() - .where( f -> f.range().field( defaultDslConverterFieldPath() ) - .between( null, value( upperDocOrdinal ) ) ) ) - .hasDocRefHitsAnyOrder( docIdRange( null, upperDocOrdinal ) ); + .where( f -> f.range().field( defaultDslConverterFieldPath( dataSet ) ) + .between( null, value( upperDocOrdinal, dataSet ) ) ) ) + .hasDocRefHitsAnyOrder( docIdRange( null, upperDocOrdinal, dataSet ) ); } - private String defaultDslConverterFieldPath() { + private String defaultDslConverterFieldPath(DataSet dataSet) { return index.binding().defaultDslConverterField.get( dataSet.fieldType ).relativeFieldName; } - private String customDslConverterFieldPath() { + private String customDslConverterFieldPath(DataSet dataSet) { return index.binding().customDslConverterField.get( dataSet.fieldType ).relativeFieldName; } - private Consumer docIdRange(Integer firstIncludedOrNull, Integer lastIncludedOrNull) { + private Consumer docIdRange(Integer firstIncludedOrNull, Integer lastIncludedOrNull, + DataSet dataSet) { int firstIncluded = firstIncludedOrNull == null ? 0 : firstIncludedOrNull; - int lastIncluded = lastIncludedOrNull == null ? docCount() - 1 : lastIncludedOrNull; + int lastIncluded = lastIncludedOrNull == null ? docCount( dataSet ) - 1 : lastIncludedOrNull; return b -> { for ( int i = firstIncluded; i <= lastIncluded; i++ ) { b.doc( index.typeName(), dataSet.docId( i ) ); @@ -290,15 +300,15 @@ private Consumer docIdRange(Integer firstIncludedOr }; } - private F value(int docOrdinal) { + private F value(int docOrdinal, DataSet dataSet) { return dataSet.values.matchingValue( docOrdinal ); } - private ValueWrapper wrappedValue(int docOrdinal) { - return new ValueWrapper<>( value( docOrdinal ) ); + private ValueWrapper wrappedValue(int docOrdinal, DataSet dataSet) { + return new ValueWrapper<>( value( docOrdinal, dataSet ) ); } - private int docCount() { + private int docCount(DataSet dataSet) { return dataSet.values.size(); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RegexpPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RegexpPredicateBaseIT.java index b391bcc637d..3788232cc1c 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RegexpPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RegexpPredicateBaseIT.java @@ -12,20 +12,19 @@ import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class RegexpPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class RegexpPredicateBaseIT { + //CHECKSTYLE:ON private static final List> supportedFieldTypes = new ArrayList<>(); private static final List> unsupportedFieldTypes = new ArrayList<>(); @@ -42,11 +41,11 @@ public class RegexpPredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -98,102 +97,76 @@ private static RegexpPredicateTestValues testValues(FieldTypeDescriptor return new RegexpPredicateTestValues( fieldType ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT { + class SingleFieldIT extends AbstractPredicateSingleFieldIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "singleField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "singleField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public SingleFieldIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.regexp().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT { + class MultiFieldIT extends AbstractPredicateMultiFieldIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "multiField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "multiField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public MultiFieldIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, DataSet dataSet) { return f.regexp().field( fieldPath ).field( otherFieldPath ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override - protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal) { + protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal, + DataSet dataSet) { return f.regexp().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, DataSet dataSet) { return f.regexp().field( fieldPath ).fields( fieldPaths ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "nesting" ); @@ -202,97 +175,100 @@ public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldI SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); + } } - public InObjectFieldIT(DataSet dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.regexp().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class ScoreIT extends AbstractPredicateFieldScoreIT { + class ScoreIT extends AbstractPredicateFieldScoreIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "score" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "score" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public ScoreIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.regexp().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.regexp().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { + int matchingDocOrdinal, float predicateBoost, DataSet dataSet) { return f.regexp().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) .boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.regexp().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore().boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.regexp().field( fieldPath ).boost( fieldBoost ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.regexp().field( fieldPath ).boost( fieldBoost ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.regexp().field( fieldPath ).boost( fieldBoost ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -312,26 +288,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) .name( "unsupportedType" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -346,15 +316,7 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class SearchableIT extends AbstractPredicateSearchableIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -363,13 +325,15 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( searchableYesIndex, searchableNoIndex, fieldType ) ); + } } - public SearchableIT(FieldTypeDescriptor fieldType) { - super( searchableYesIndex, searchableNoIndex, fieldType ); + public static List params() { + return parameters; } @Override @@ -384,26 +348,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "argumentChecking" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public ArgumentCheckingIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -413,24 +371,8 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - @RunWith(Parameterized.class) - public static class TypeCheckingNoConversionIT + class TypeCheckingNoConversionIT extends AbstractPredicateTypeCheckingNoConversionIT { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; - } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_main" ); @@ -447,18 +389,30 @@ public static List parameters() { SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - public TypeCheckingNoConversionIT(DataSet dataSet) { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, + incompatibleIndex, dataSet ) ); + } + } + + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.regexp().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, String field0Path, String field1Path, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.regexp().field( field0Path ).field( field1Path ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RegexpPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RegexpPredicateSpecificsIT.java index fa255ed1303..8c98192945e 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RegexpPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/RegexpPredicateSpecificsIT.java @@ -21,16 +21,16 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.NormalizedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class RegexpPredicateSpecificsIT { +class RegexpPredicateSpecificsIT { private static final String DOCUMENT_1 = "document1"; private static final String DOCUMENT_2 = "document2"; @@ -61,15 +61,15 @@ public class RegexpPredicateSpecificsIT { private static final String TEXT_ANYSTRING_MATCHING = "abcabc"; private static final String TEXT_ANYSTRING_NOT_MATCHING = "foo99"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private static final DataSet dataSet = new DataSet(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -78,7 +78,7 @@ public static void setup() { } @Test - public void analyzedField() { + void analyzedField() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedField.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -96,7 +96,7 @@ public void analyzedField() { } @Test - public void normalizedField() { + void normalizedField() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().normalizedField.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -118,7 +118,7 @@ public void normalizedField() { } @Test - public void nonAnalyzedField() { + void nonAnalyzedField() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().nonAnalyzedField.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -133,7 +133,7 @@ public void nonAnalyzedField() { } @Test - public void moreCases() { + void moreCases() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().nonAnalyzedField.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -150,7 +150,7 @@ public void moreCases() { } @Test - public void emptyString() { + void emptyString() { String absoluteFieldPath = index.binding().analyzedField.relativeFieldName; assertThatQuery( index.query() @@ -159,7 +159,7 @@ public void emptyString() { } @Test - public void flag_interval() { + void flag_interval() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().intervalField.relativeFieldName; @@ -202,7 +202,7 @@ public void flag_interval() { } @Test - public void flag_intersection() { + void flag_intersection() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().intersectionField.relativeFieldName; @@ -245,7 +245,7 @@ public void flag_intersection() { } @Test - public void flag_anyString() { + void flag_anyString() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().anyStringField.relativeFieldName; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SearchPredicateIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SearchPredicateIT.java index 9cc78a7042a..ea37a93f919 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SearchPredicateIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SearchPredicateIT.java @@ -24,17 +24,17 @@ import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactoryExtension; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchPredicateIT { +class SearchPredicateIT { private static final String DOCUMENT_1 = "doc1"; private static final String DOCUMENT_2 = "doc2"; @@ -43,8 +43,8 @@ public class SearchPredicateIT { private static final String STRING_1 = "Irving"; private static final String STRING_2 = "Auster"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -53,15 +53,15 @@ public class SearchPredicateIT { // What matters here is that is a different index. SimpleMappedIndex.of( IndexBinding::new ).name( "other" ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndexes( mainIndex, otherIndex ).setup(); initData(); } @Test - public void where_searchPredicate() { + void where_searchPredicate() { StubMappingScope scope = mainIndex.createScope(); SearchPredicate predicate = scope.predicate().match().field( "string" ).matching( STRING_1 ).toPredicate(); @@ -75,7 +75,7 @@ public void where_searchPredicate() { } @Test - public void where_lambda() { + void where_lambda() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -87,7 +87,7 @@ public void where_lambda() { } @Test - public void reuseRootPredicateInstance_onScopeTargetingSameIndexes() { + void reuseRootPredicateInstance_onScopeTargetingSameIndexes() { StubMappingScope scope = mainIndex.createScope(); SearchPredicate predicate = scope .predicate().match().field( "string" ).matching( STRING_1 ).toPredicate(); @@ -126,7 +126,7 @@ public void reuseRootPredicateInstance_onScopeTargetingSameIndexes() { } @Test - public void reuseRootPredicateInstance_onScopeTargetingDifferentIndexes() { + void reuseRootPredicateInstance_onScopeTargetingDifferentIndexes() { StubMappingScope scope = mainIndex.createScope(); SearchPredicate predicate = scope .predicate().match().field( "string" ).matching( STRING_1 ).toPredicate(); @@ -154,7 +154,7 @@ public void reuseRootPredicateInstance_onScopeTargetingDifferentIndexes() { } @Test - public void reuseNonRootPredicateInstance_onScopeTargetingSameIndexes() { + void reuseNonRootPredicateInstance_onScopeTargetingSameIndexes() { StubMappingScope scope = mainIndex.createScope(); final SearchPredicate predicate = scope .predicate().match().field( "string" ).matching( STRING_1 ).toPredicate(); @@ -202,7 +202,7 @@ public void reuseNonRootPredicateInstance_onScopeTargetingSameIndexes() { } @Test - public void reuseNonRootPredicateInstance_onScopeTargetingDifferentIndexes() { + void reuseNonRootPredicateInstance_onScopeTargetingDifferentIndexes() { StubMappingScope scope = mainIndex.createScope(); SearchPredicate predicate = scope .predicate().match().field( "string" ).matching( STRING_1 ).toPredicate(); @@ -230,7 +230,7 @@ public void reuseNonRootPredicateInstance_onScopeTargetingDifferentIndexes() { } @Test - public void extension() { + void extension() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query; @@ -307,21 +307,21 @@ public void extension() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath() { + void toAbsolutePath() { assertThat( mainIndex.createScope().predicate().toAbsolutePath( "string" ) ) .isEqualTo( "string" ); } @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_withRoot() { + void toAbsolutePath_withRoot() { assertThat( mainIndex.createScope().predicate().withRoot( "flattened" ).toAbsolutePath( "string" ) ) .isEqualTo( "flattened.string" ); } @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_null() { + void toAbsolutePath_null() { assertThatThrownBy( () -> mainIndex.createScope().predicate().toAbsolutePath( null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContaining( "'relativeFieldPath' must not be null" ); @@ -329,7 +329,7 @@ public void toAbsolutePath_null() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_withRoot_null() { + void toAbsolutePath_withRoot_null() { assertThatThrownBy( () -> mainIndex.createScope().predicate().withRoot( "flattened" ).toAbsolutePath( null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContaining( "'relativeFieldPath' must not be null" ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SimpleQueryStringPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SimpleQueryStringPredicateBaseIT.java index 7a074e1b2af..051815a3cc2 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SimpleQueryStringPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SimpleQueryStringPredicateBaseIT.java @@ -12,21 +12,19 @@ import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.AssumptionViolatedException; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class SimpleQueryStringPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class SimpleQueryStringPredicateBaseIT { + //CHECKSTYLE:ON private static final List> supportedFieldTypes = new ArrayList<>(); private static final List> unsupportedFieldTypes = new ArrayList<>(); @@ -43,11 +41,11 @@ public class SimpleQueryStringPredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -108,103 +106,77 @@ private static SimpleQueryStringPredicateTestValues testValues(FieldTypeDescript return new SimpleQueryStringPredicateTestValues( fieldType ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT { + class SingleFieldIT extends AbstractPredicateSingleFieldIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "singleField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "singleField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public SingleFieldIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.simpleQueryString().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT { + class MultiFieldIT extends AbstractPredicateMultiFieldIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "multiField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "multiField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public MultiFieldIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, DataSet dataSet) { return f.simpleQueryString().field( fieldPath ).field( otherFieldPath ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override - protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal) { + protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal, + DataSet dataSet) { return f.simpleQueryString().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, DataSet dataSet) { return f.simpleQueryString().field( fieldPath ).fields( fieldPaths ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class InObjectFieldIT + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "nesting" ); @@ -213,23 +185,29 @@ public static class InObjectFieldIT SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); + } } - public InObjectFieldIT(DataSet dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.simpleQueryString().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - public static class AnalysisIT extends AbstractPredicateConfigurableAnalysisIT { + class AnalysisIT extends AbstractPredicateConfigurableAnalysisIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) @@ -262,88 +240,99 @@ protected PredicateFinalStep predicateWithSkipAnalysis(SearchPredicateFactory f, } @Nested - @RunWith(Parameterized.class) - public static class ScoreIT extends AbstractPredicateFieldScoreIT { + class ScoreIT extends AbstractPredicateFieldScoreIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "score" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "score" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public ScoreIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override - public void constantScore_fieldLevelBoost() { - throw new AssumptionViolatedException( + public void constantScore_fieldLevelBoost(SimpleMappedIndex index, + DataSet dataSet) { + throw new org.opentest4j.TestAbortedException( "The simpleQueryString predicate currently does not fail when using constantScore() + a field-level boost" ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.simpleQueryString().field( fieldPath ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .matching( ( (DataSet) dataSet ).values + .matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.simpleQueryString().fields( fieldPaths ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); + .matching( ( (DataSet) dataSet ).values + .matchingArg( matchingDocOrdinal ) ) + .constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { + int matchingDocOrdinal, float predicateBoost, DataSet dataSet) { return f.simpleQueryString().fields( fieldPaths ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); + .matching( ( (DataSet) dataSet ).values + .matchingArg( matchingDocOrdinal ) ) + .boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.simpleQueryString().fields( fieldPaths ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore().boost( predicateBoost ); + .matching( ( (DataSet) dataSet ).values + .matchingArg( matchingDocOrdinal ) ) + .constantScore().boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.simpleQueryString().field( fieldPath ).boost( fieldBoost ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .matching( ( (DataSet) dataSet ).values + .matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, + DataSet dataSet) { return f.simpleQueryString().field( fieldPath ).boost( fieldBoost ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); + .matching( ( (DataSet) dataSet ).values + .matchingArg( matchingDocOrdinal ) ) + .constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.simpleQueryString().field( fieldPath ).boost( fieldBoost ) - .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); + .matching( ( (DataSet) dataSet ).values + .matchingArg( matchingDocOrdinal ) ) + .boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -363,26 +352,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) .name( "unsupportedType" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -397,15 +380,7 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class SearchableIT extends AbstractPredicateSearchableIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -414,13 +389,15 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( searchableYesIndex, searchableNoIndex, fieldType ) ); + } } - public SearchableIT(FieldTypeDescriptor fieldType) { - super( searchableYesIndex, searchableNoIndex, fieldType ); + public static List params() { + return parameters; } @Override @@ -435,26 +412,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "argumentChecking" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public ArgumentCheckingIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -464,24 +435,8 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - @RunWith(Parameterized.class) - public static class TypeCheckingNoConversionIT + class TypeCheckingNoConversionIT extends AbstractPredicateTypeCheckingNoConversionIT { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; - } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_main" ); @@ -498,18 +453,30 @@ public static List parameters() { SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - public TypeCheckingNoConversionIT(DataSet dataSet) { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, + incompatibleIndex, dataSet ) ); + } + } + + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.simpleQueryString().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, String field0Path, String field1Path, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.simpleQueryString().field( field0Path ).field( field1Path ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SimpleQueryStringPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SimpleQueryStringPredicateSpecificsIT.java index 18351721258..6dfd1278d78 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SimpleQueryStringPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SimpleQueryStringPredicateSpecificsIT.java @@ -25,7 +25,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.AnalyzedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; @@ -33,11 +33,11 @@ import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SimpleQueryStringPredicateSpecificsIT { +class SimpleQueryStringPredicateSpecificsIT { private static final String DOCUMENT_1 = "document1"; private static final String DOCUMENT_2 = "document2"; @@ -61,15 +61,15 @@ public class SimpleQueryStringPredicateSpecificsIT { private static final String TEXT_TERM_4_IN_PHRASE_SLOP_2 = "An elephant ran past John."; private static final String TEXT_TERM_1_EDIT_DISTANCE_1_OR_TERM_6 = "I came to the world in a dumpster."; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private static final DataSet dataSet = new DataSet(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -80,7 +80,7 @@ public static void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-2678") @PortedFromSearch5(original = "org.hibernate.search.test.dsl.SimpleQueryStringDSLTest.testSimpleQueryString") - public void booleanOperators() { + void booleanOperators() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -105,7 +105,7 @@ public void booleanOperators() { @Test @TestForIssue(jiraKey = "HSEARCH-3847") - public void booleanOperators_flags() { + void booleanOperators_flags() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; @@ -198,7 +198,7 @@ public void booleanOperators_flags() { @Test @TestForIssue(jiraKey = "HSEARCH-3844") // Used to throw NPE - public void nonAnalyzedField() { + void nonAnalyzedField() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().nonAnalyzedField.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -224,7 +224,7 @@ public void nonAnalyzedField() { @Test @TestForIssue(jiraKey = "HSEARCH-2678") @PortedFromSearch5(original = "org.hibernate.search.test.dsl.SimpleQueryStringDSLTest.testSimpleQueryString") - public void defaultOperator() { + void defaultOperator() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; SearchQuery query; @@ -256,7 +256,7 @@ public void defaultOperator() { @Test @TestForIssue(jiraKey = "HSEARCH-2678") @PortedFromSearch5(original = "org.hibernate.search.test.dsl.SimpleQueryStringDSLTest.testSimpleQueryString") - public void phrase() { + void phrase() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -282,7 +282,7 @@ public void phrase() { @Test @TestForIssue(jiraKey = "HSEARCH-3847") - public void phrase_flag() { + void phrase_flag() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; @@ -331,7 +331,7 @@ public void phrase_flag() { @Test @TestForIssue(jiraKey = "HSEARCH-2678") @PortedFromSearch5(original = "org.hibernate.search.test.dsl.SimpleQueryStringDSLTest.testFuzzy") - public void fuzzy() { + void fuzzy() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -350,7 +350,7 @@ public void fuzzy() { @Test @TestForIssue(jiraKey = "HSEARCH-3847") - public void fuzzy_flag() { + void fuzzy_flag() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; @@ -376,7 +376,7 @@ public void fuzzy_flag() { } @Test - public void prefix() { + void prefix() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; @@ -393,7 +393,7 @@ public void prefix() { @Test @TestForIssue(jiraKey = "HSEARCH-3847") - public void prefix_flag() { + void prefix_flag() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; @@ -420,7 +420,7 @@ public void prefix_flag() { @Test @TestForIssue(jiraKey = { "HSEARCH-3612", "HSEARCH-3845" }) - public void prefix_normalizePrefixTerm() { + void prefix_normalizePrefixTerm() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; @@ -437,7 +437,7 @@ public void prefix_normalizePrefixTerm() { @Test @TestForIssue(jiraKey = "HSEARCH-3847") - public void whitespace() { + void whitespace() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().nonAnalyzedField.relativeFieldName; @@ -457,7 +457,7 @@ public void whitespace() { @Test @TestForIssue(jiraKey = "HSEARCH-3847") - public void escape() { + void escape() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; @@ -476,7 +476,7 @@ public void escape() { } @Test - public void incompatibleNestedPaths() { + void incompatibleNestedPaths() { String fieldInRootPath = index.binding().analyzedStringField1.relativeFieldName; String fieldInNestedPath = index.binding().nested.fieldPath(); assertThatThrownBy( () -> index.createScope() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinBoundingBoxPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinBoundingBoxPredicateBaseIT.java index 315ebdbd0a2..15ee4ff2150 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinBoundingBoxPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinBoundingBoxPredicateBaseIT.java @@ -7,6 +7,7 @@ package org.hibernate.search.integrationtest.backend.tck.search.predicate; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; @@ -14,20 +15,19 @@ import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class SpatialWithinBoundingBoxPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class SpatialWithinBoundingBoxPredicateBaseIT { + //CHECKSTYLE:ON private static final GeoPointFieldTypeDescriptor supportedFieldType; private static final List> supportedFieldTypes = new ArrayList<>(); @@ -42,11 +42,11 @@ public class SpatialWithinBoundingBoxPredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -97,13 +97,8 @@ private static SpatialWithinBoundingBoxPredicateTestValues testValues() { return new SpatialWithinBoundingBoxPredicateTestValues(); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT { + class SingleFieldIT extends AbstractPredicateSingleFieldIT { private static final DataSet dataSet = new DataSet<>( testValues() ); @@ -111,19 +106,20 @@ public static class SingleFieldIT extends AbstractPredicateSingleFieldIT new IndexBinding( root, supportedFieldTypes ) ) .name( "singleField" ); - public SingleFieldIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .boundingBox( SingleFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT { + class MultiFieldIT extends AbstractPredicateMultiFieldIT { private static final DataSet dataSet = new DataSet<>( testValues() ); @@ -131,33 +127,36 @@ public static class MultiFieldIT extends AbstractPredicateMultiFieldIT new IndexBinding( root, supportedFieldTypes ) ) .name( "multiField" ); - public MultiFieldIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ).field( otherFieldPath ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .boundingBox( MultiFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override - protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal) { + protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .boundingBox( MultiFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ).fields( fieldPaths ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .boundingBox( MultiFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - public static class InObjectFieldIT + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { private static final DataSet dataSet = new DataSet<>( testValues() ); @@ -170,18 +169,22 @@ public static class InObjectFieldIT SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - public InObjectFieldIT() { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return Arrays.asList( + Arguments.of( mainIndex, missingFieldIndex, dataSet ) + ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { - return f.spatial().within().field( fieldPath ).boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { + return f.spatial().within().field( fieldPath ) + .boundingBox( InObjectFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - public static class ScoreIT extends AbstractPredicateFieldScoreIT { + class ScoreIT extends AbstractPredicateFieldScoreIT { private static final DataSet dataSet = new DataSet<>( testValues() ); @@ -189,61 +192,65 @@ public static class ScoreIT extends AbstractPredicateFieldScoreIT new IndexBinding( root, supportedFieldTypes ) ) .name( "score" ); - public ScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .boundingBox( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); + .boundingBox( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { + int matchingDocOrdinal, float predicateBoost, DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); + .boundingBox( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); + .boundingBox( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().field( fieldPath ).boost( fieldBoost ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .boundingBox( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ).boost( fieldBoost ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); + .boundingBox( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.spatial().within().field( fieldPath ).boost( fieldBoost ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); + .boundingBox( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -265,26 +272,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) .name( "unsupportedType" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -301,7 +302,7 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class SearchableIT extends AbstractPredicateSearchableIT { + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -310,8 +311,8 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - public SearchableIT() { - super( searchableYesIndex, searchableNoIndex, supportedFieldType ); + public static List params() { + return Arrays.asList( Arguments.of( searchableYesIndex, searchableNoIndex, supportedFieldType ) ); } @Override @@ -328,13 +329,13 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "argumentChecking" ); - public ArgumentCheckingIT() { - super( index, supportedFieldType ); + public static List params() { + return Arrays.asList( Arguments.of( index, supportedFieldType ) ); } @Override @@ -344,7 +345,7 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - public static class TypeCheckingNoConversionIT + class TypeCheckingNoConversionIT extends AbstractPredicateTypeCheckingNoConversionIT { private static final DataSet dataSet = new DataSet<>( testValues() ); @@ -365,20 +366,23 @@ public static class TypeCheckingNoConversionIT SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - public TypeCheckingNoConversionIT() { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, + incompatibleIndex, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { - return f.spatial().within().field( fieldPath ).boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { + return f.spatial().within().field( fieldPath ) + .boundingBox( TypeCheckingNoConversionIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, String field0Path, String field1Path, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().field( field0Path ).field( field1Path ) - .boundingBox( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .boundingBox( TypeCheckingNoConversionIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinBoundingBoxPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinBoundingBoxPredicateSpecificsIT.java index 57834ef5e13..854b18ccc5c 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinBoundingBoxPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinBoundingBoxPredicateSpecificsIT.java @@ -11,9 +11,9 @@ import org.hibernate.search.engine.spatial.GeoBoundingBox; import org.hibernate.search.engine.spatial.GeoPoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SpatialWithinBoundingBoxPredicateSpecificsIT extends AbstractSpatialWithinPredicateIT { +class SpatialWithinBoundingBoxPredicateSpecificsIT extends AbstractSpatialWithinPredicateIT { private static final GeoBoundingBox BOUNDING_BOX_1 = GeoBoundingBox.of( GeoPoint.of( 45.785889, 4.819749 ), @@ -32,7 +32,7 @@ public class SpatialWithinBoundingBoxPredicateSpecificsIT extends AbstractSpatia private static final GeoPoint ADDITIONAL_POINT_2_GEO_POINT = GeoPoint.of( 24.5, 23.5 ); @Test - public void matchMultipleDocuments() { + void matchMultipleDocuments() { assertThatQuery( mainIndex.query() .where( f -> f.spatial().within().field( "geoPoint" ).boundingBox( BOUNDING_BOX_2 ) ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), IMOUTO_ID, CHEZ_MARGOTTE_ID ); @@ -55,7 +55,7 @@ public void matchMultipleDocuments() { } @Test - public void consistency() { + void consistency() { assertThatQuery( mainIndex.query() .where( f -> f.spatial().within().field( "geoPoint" ) .boundingBox( GeoBoundingBox.of( GeoPoint.of( 25, 23 ), GeoPoint.of( 24, 26 ) ) ) ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinCirclePredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinCirclePredicateBaseIT.java index e8126c5ee18..536f42634f7 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinCirclePredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinCirclePredicateBaseIT.java @@ -9,6 +9,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; @@ -16,20 +17,21 @@ import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(NestedRunner.class) -public class SpatialWithinCirclePredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class SpatialWithinCirclePredicateBaseIT { + //CHECKSTYLE:ON private static final GeoPointFieldTypeDescriptor supportedFieldType; private static final List> supportedFieldTypes = new ArrayList<>(); @@ -44,11 +46,11 @@ public class SpatialWithinCirclePredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -99,69 +101,66 @@ private static SpatialWithinCirclePredicateTestValues testValues() { return new SpatialWithinCirclePredicateTestValues(); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT { + class SingleFieldIT extends AbstractPredicateSingleFieldIT { private static final DataSet dataSet = new DataSet<>( testValues() ); private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "singleField" ); - public SingleFieldIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ); + .circle( SingleFieldIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + SingleFieldIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ); } } @Nested - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT { + class MultiFieldIT extends AbstractPredicateMultiFieldIT { private static final DataSet dataSet = new DataSet<>( testValues() ); private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "multiField" ); - public MultiFieldIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().field( fieldPath ).field( otherFieldPath ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ); + .circle( MultiFieldIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + MultiFieldIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ); } @Override - protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal) { + protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ); + .circle( MultiFieldIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + MultiFieldIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().field( fieldPath ).fields( fieldPaths ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ); + .circle( MultiFieldIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + MultiFieldIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ); } } @Nested - public static class InObjectFieldIT + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { private static final DataSet dataSet = new DataSet<>( testValues() ); @@ -174,93 +173,98 @@ public static class InObjectFieldIT SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - public InObjectFieldIT() { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ); + .circle( InObjectFieldIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + InObjectFieldIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ); } } @Nested - public static class ScoreIT extends AbstractPredicateFieldScoreIT { + class ScoreIT extends AbstractPredicateFieldScoreIT { private static final DataSet dataSet = new DataSet<>( testValues() ); private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "score" ); - public ScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ); + .circle( ScoreIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + ScoreIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ) + .circle( ScoreIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + ScoreIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { + int matchingDocOrdinal, float predicateBoost, DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ) + .circle( ScoreIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + ScoreIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ) .boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ) + .circle( ScoreIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + ScoreIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ) .constantScore().boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().field( fieldPath ).boost( fieldBoost ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ); + .circle( ScoreIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + ScoreIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ).boost( fieldBoost ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ) + .circle( ScoreIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + ScoreIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.spatial().within().field( fieldPath ).boost( fieldBoost ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ) + .circle( ScoreIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + ScoreIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ) .boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -282,26 +286,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) .name( "unsupportedType" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -318,7 +316,7 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class SearchableIT extends AbstractPredicateSearchableIT { + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -327,8 +325,8 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - public SearchableIT() { - super( searchableYesIndex, searchableNoIndex, supportedFieldType ); + public static List params() { + return Arrays.asList( Arguments.of( searchableYesIndex, searchableNoIndex, supportedFieldType ) ); } @Override @@ -345,20 +343,22 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "argumentChecking" ); - public ArgumentCheckingIT() { - super( index, supportedFieldType ); + public static List params() { + return Arrays.asList( Arguments.of( index, supportedFieldType ) ); } - @Test - public void nullUnit() { + @ParameterizedTest(name = "{1}") + @MethodSource("params") + void nullUnit(SimpleMappedIndex index, FieldTypeDescriptor fieldType) { SearchPredicateFactory f = index.createScope().predicate(); - assertThatThrownBy( () -> f.spatial().within().field( fieldPath() ).circle( 0.0, 0.0, 10.0, null ) ) + assertThatThrownBy( + () -> f.spatial().within().field( fieldPath( index, fieldType ) ).circle( 0.0, 0.0, 10.0, null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContainingAll( "must not be null" ); } @@ -370,7 +370,7 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - public static class TypeCheckingNoConversionIT + class TypeCheckingNoConversionIT extends AbstractPredicateTypeCheckingNoConversionIT { private static final DataSet dataSet = new DataSet<>( testValues() ); @@ -390,23 +390,27 @@ public static class TypeCheckingNoConversionIT SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - public TypeCheckingNoConversionIT() { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + public static List params() { + return Arrays.asList( + Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, + dataSet ) + ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ); + .circle( TypeCheckingNoConversionIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + TypeCheckingNoConversionIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, String field0Path, String field1Path, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().field( field0Path ).field( field1Path ) - .circle( dataSet.values.matchingCenter( matchingDocOrdinal ), - dataSet.values.matchingRadius( matchingDocOrdinal ) ); + .circle( TypeCheckingNoConversionIT.dataSet.values.matchingCenter( matchingDocOrdinal ), + TypeCheckingNoConversionIT.dataSet.values.matchingRadius( matchingDocOrdinal ) ); } @Override diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinCirclePredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinCirclePredicateSpecificsIT.java index 8702a3b15e1..c48d9182f67 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinCirclePredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinCirclePredicateSpecificsIT.java @@ -11,15 +11,15 @@ import org.hibernate.search.engine.spatial.DistanceUnit; import org.hibernate.search.engine.spatial.GeoPoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SpatialWithinCirclePredicateSpecificsIT extends AbstractSpatialWithinPredicateIT { +class SpatialWithinCirclePredicateSpecificsIT extends AbstractSpatialWithinPredicateIT { private static final GeoPoint METRO_HOTEL_DE_VILLE = GeoPoint.of( 45.7673396, 4.833743 ); private static final GeoPoint METRO_GARIBALDI = GeoPoint.of( 45.7515926, 4.8514779 ); @Test - public void matchMultipleDocuments() { + void matchMultipleDocuments() { assertThatQuery( mainIndex.query() .where( f -> f.spatial().within() .field( "geoPoint" ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinPolygonPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinPolygonPredicateBaseIT.java index c81be4acc7c..c45eb2f0436 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinPolygonPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinPolygonPredicateBaseIT.java @@ -7,6 +7,7 @@ package org.hibernate.search.integrationtest.backend.tck.search.predicate; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; @@ -15,20 +16,19 @@ import org.hibernate.search.engine.spatial.GeoPolygon; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class SpatialWithinPolygonPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class SpatialWithinPolygonPredicateBaseIT { + //CHECKSTYLE:ON private static final GeoPointFieldTypeDescriptor supportedFieldType; private static final List> supportedFieldTypes = new ArrayList<>(); @@ -43,11 +43,11 @@ public class SpatialWithinPolygonPredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -103,64 +103,63 @@ private static GeoPolygon unsusedPolygon() { GeoPoint.of( 0.0, 1.0 ), GeoPoint.of( 0.0, 0.0 ) ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT { + class SingleFieldIT extends AbstractPredicateSingleFieldIT { private static final DataSet dataSet = new DataSet<>( testValues() ); private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "singleField" ); - public SingleFieldIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .polygon( SingleFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT { + class MultiFieldIT extends AbstractPredicateMultiFieldIT { private static final DataSet dataSet = new DataSet<>( testValues() ); private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "multiField" ); - public MultiFieldIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().field( fieldPath ).field( otherFieldPath ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .polygon( MultiFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override - protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal) { - return f.spatial().within().fields( fieldPaths ).polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ); + protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal, + DataSet dataSet) { + return f.spatial().within().fields( fieldPaths ) + .polygon( MultiFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ).fields( fieldPaths ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .polygon( MultiFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - public static class InObjectFieldIT + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { private static final DataSet dataSet = new DataSet<>( testValues() ); @@ -173,80 +172,86 @@ public static class InObjectFieldIT SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - public InObjectFieldIT() { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { - return f.spatial().within().field( fieldPath ).polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { + return f.spatial().within().field( fieldPath ) + .polygon( InObjectFieldIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - public static class ScoreIT extends AbstractPredicateFieldScoreIT { + class ScoreIT extends AbstractPredicateFieldScoreIT { private static final DataSet dataSet = new DataSet<>( testValues() ); private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "score" ); - public ScoreIT() { - super( index, dataSet ); + public static List params() { + return Arrays.asList( Arguments.of( index, dataSet ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { - return f.spatial().within().field( fieldPath ).polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { + return f.spatial().within().field( fieldPath ).polygon( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); + .polygon( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { + int matchingDocOrdinal, float predicateBoost, DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); + .polygon( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.spatial().within().fields( fieldPaths ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ) + .polygon( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore().boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().field( fieldPath ).boost( fieldBoost ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .polygon( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, + DataSet dataSet) { return f.spatial().within().field( fieldPath ).boost( fieldBoost ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ) + .polygon( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.spatial().within().field( fieldPath ).boost( fieldBoost ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); + .polygon( ScoreIT.dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -268,26 +273,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) .name( "unsupportedType" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -304,7 +303,7 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class SearchableIT extends AbstractPredicateSearchableIT { + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -313,8 +312,8 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - public SearchableIT() { - super( searchableYesIndex, searchableNoIndex, supportedFieldType ); + public static List params() { + return Arrays.asList( Arguments.of( searchableYesIndex, searchableNoIndex, supportedFieldType ) ); } @Override @@ -331,13 +330,13 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "argumentChecking" ); - public ArgumentCheckingIT() { - super( index, supportedFieldType ); + public static List params() { + return Arrays.asList( Arguments.of( index, supportedFieldType ) ); } @Override @@ -347,7 +346,7 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - public static class TypeCheckingNoConversionIT + class TypeCheckingNoConversionIT extends AbstractPredicateTypeCheckingNoConversionIT { private static final DataSet dataSet = new DataSet<>( testValues() ); @@ -367,20 +366,25 @@ public static class TypeCheckingNoConversionIT SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - public TypeCheckingNoConversionIT() { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + public static List params() { + return Arrays.asList( + Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, + dataSet + ) ); } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { - return f.spatial().within().field( fieldPath ).polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ); + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { + return f.spatial().within().field( fieldPath ) + .polygon( TypeCheckingNoConversionIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, String field0Path, String field1Path, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.spatial().within().field( field0Path ).field( field1Path ) - .polygon( dataSet.values.matchingArg( matchingDocOrdinal ) ); + .polygon( TypeCheckingNoConversionIT.dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinPolygonPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinPolygonPredicateSpecificsIT.java index 7da7e98555c..2fcad336967 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinPolygonPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/SpatialWithinPolygonPredicateSpecificsIT.java @@ -11,9 +11,9 @@ import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.engine.spatial.GeoPolygon; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SpatialWithinPolygonPredicateSpecificsIT extends AbstractSpatialWithinPredicateIT { +class SpatialWithinPolygonPredicateSpecificsIT extends AbstractSpatialWithinPredicateIT { private static final GeoPolygon POLYGON_1 = GeoPolygon.of( GeoPoint.of( 45.785889, 4.819749 ), @@ -40,7 +40,7 @@ public class SpatialWithinPolygonPredicateSpecificsIT extends AbstractSpatialWit ); @Test - public void matchMultipleDocuments() { + void matchMultipleDocuments() { assertThatQuery( mainIndex.query() .where( f -> f.spatial().within().field( "geoPoint" ).polygon( POLYGON_2 ) ) ) .hasDocRefHitsAnyOrder( mainIndex.typeName(), IMOUTO_ID, CHEZ_MARGOTTE_ID ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateAnalyzedFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateAnalyzedFieldIT.java index 9f411326a77..f44e3655345 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateAnalyzedFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateAnalyzedFieldIT.java @@ -11,32 +11,32 @@ import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class TermsPredicateAnalyzedFieldIT { +class TermsPredicateAnalyzedFieldIT { private static final String DOC_ID = "my_only_document"; private static final String[] TOKENS = { "be", "have", "do", "say", "will", "would", "get" }; private static final String[] NOT_PRESENT_TOKENS = { "go", "make", "can", "time" }; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndexes( index ).setup(); initData(); } @Test - public void matchingAny_rightTerms() { + void matchingAny_rightTerms() { for ( String token : TOKENS ) { assertThatQuery( index.query().where( f -> f.terms().field( "analyzedField" ).matchingAny( token ) ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOC_ID ); @@ -44,7 +44,7 @@ public void matchingAny_rightTerms() { } @Test - public void matchingAny_wrongTerms() { + void matchingAny_wrongTerms() { for ( String token : NOT_PRESENT_TOKENS ) { assertThatQuery( index.query().where( f -> f.terms().field( "analyzedField" ).matchingAny( token ) ) ) .hasNoHits(); @@ -52,14 +52,14 @@ public void matchingAny_wrongTerms() { } @Test - public void matchingAll_someTerms() { + void matchingAll_someTerms() { assertThatQuery( index.query().where( f -> f.terms().field( "analyzedField" ) .matchingAll( TOKENS[0], TOKENS[1], TOKENS[3] ) ) ) .hasDocRefHitsAnyOrder( index.typeName(), DOC_ID ); } @Test - public void matchingAll_allTerms() { + void matchingAll_allTerms() { assertThatQuery( index.query().where( f -> f .terms().field( "analyzedField" ) .matchingAll( TOKENS[0], TOKENS[1], TOKENS[2], TOKENS[3], TOKENS[4], TOKENS[5], TOKENS[6] ) ) ) @@ -67,7 +67,7 @@ public void matchingAll_allTerms() { } @Test - public void matchingAll_oneWrongTerm() { + void matchingAll_oneWrongTerm() { assertThatQuery( index.query().where( f -> f .terms().field( "analyzedField" ) .matchingAll( TOKENS[0], TOKENS[1], NOT_PRESENT_TOKENS[1] ) ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateBaseIT.java index 26f6c6769f4..8f6e9ede9b4 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateBaseIT.java @@ -17,20 +17,19 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.InvalidType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class TermsPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class TermsPredicateBaseIT { + //CHECKSTYLE:ON private static final List> supportedFieldTypes = new ArrayList<>(); private static final List> unsupportedFieldTypes = new ArrayList<>(); @@ -46,11 +45,11 @@ public class TermsPredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -117,73 +116,58 @@ private static TermsPredicateTestValues testValues(FieldTypeDescriptor return new TermsPredicateTestValues<>( fieldType ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class SingleFieldIT extends AbstractPredicateSingleFieldIT> { + class SingleFieldIT extends AbstractPredicateSingleFieldIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "singleField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "singleField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public SingleFieldIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.terms().field( fieldPath ).matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class MultipleArgumentIT extends AbstractPredicateSingleFieldIT> { + class MultipleArgumentIT extends AbstractPredicateSingleFieldIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "multipleArgumentField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "multipleArgumentField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public MultipleArgumentIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { if ( dataSet.values.providesNonMatchingArgs() ) { return f.terms().field( fieldPath ).matchingAny( dataSet.values.nonMatchingArg( 0 ), dataSet.values.matchingArg( matchingDocOrdinal ), dataSet.values.nonMatchingArg( 1 ), @@ -196,67 +180,49 @@ protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPat } @Nested - @RunWith(Parameterized.class) - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT> { + class MultiFieldIT extends AbstractPredicateMultiFieldIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "multiField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "multiField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public MultiFieldIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, DataSet> dataSet) { return f.terms().field( fieldPath ).field( otherFieldPath ) .matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet> dataSet) { return f.terms().fields( fieldPaths ).matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, DataSet> dataSet) { return f.terms().field( fieldPath ).fields( fieldPaths ) .matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT> { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT> { private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "nesting" ); @@ -265,98 +231,102 @@ public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFie SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); + } } - public InObjectFieldIT(DataSet> dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.terms().field( fieldPath ).matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class ScoreIT extends AbstractPredicateFieldScoreIT> { + class ScoreIT extends AbstractPredicateFieldScoreIT> { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "score" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "score" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public ScoreIT(DataSet> dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet> dataSet) { return f.terms().field( fieldPath ).matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet> dataSet) { return f.terms().fields( fieldPaths ).matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { + int matchingDocOrdinal, float predicateBoost, DataSet> dataSet) { return f.terms().fields( fieldPaths ).matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ) .boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet> dataSet) { return f.terms().fields( fieldPaths ).matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore().boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet> dataSet) { return f.terms().field( fieldPath ).boost( fieldBoost ) .matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, DataSet> dataSet) { return f.terms().field( fieldPath ).boost( fieldBoost ) .matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet> dataSet) { return f.terms().field( fieldPath ).boost( fieldBoost ) .matchingAny( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -376,29 +346,23 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) + .name( "unsupportedType" ); + + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); + parameters.add( Arguments.of( index, fieldType ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) - .name( "unsupportedType" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); - } - @Override protected void tryPredicate(SearchPredicateFactory f, String fieldPath) { f.terms().field( fieldPath ); @@ -411,16 +375,7 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class SearchableIT extends AbstractPredicateSearchableIT { - private static final List parameters = new ArrayList<>(); - - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -429,13 +384,16 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( searchableYesIndex, searchableNoIndex, fieldType ) ); + } } - public SearchableIT(FieldTypeDescriptor fieldType) { - super( searchableYesIndex, searchableNoIndex, fieldType ); + public static List params() { + return parameters; } @Override @@ -450,29 +408,23 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { - private static final List parameters = new ArrayList<>(); + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "argumentChecking" ); + + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); + parameters.add( Arguments.of( index, fieldType ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "argumentChecking" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public ArgumentCheckingIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); - } - @Override protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, String fieldPath) { f.terms().field( fieldPath ).matchingAny( null ); @@ -480,20 +432,8 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - @RunWith(Parameterized.class) - public static class TypeCheckingAndConversionIT + class TypeCheckingAndConversionIT extends AbstractPredicateTypeCheckingAndConversionIT, Object> { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_main" ); @@ -510,13 +450,20 @@ public static class TypeCheckingAndConversionIT SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, + incompatibleIndex, dataSet ) ); + } } - public TypeCheckingAndConversionIT(DataSet> dataSet) { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + public static List params() { + return parameters; } @Override @@ -543,12 +490,12 @@ protected Object invalidTypeParam() { } @Override - protected Object unwrappedMatchingParam(int matchingDocOrdinal) { + protected Object unwrappedMatchingParam(int matchingDocOrdinal, DataSet> dataSet) { return dataSet.values.matchingArg( matchingDocOrdinal ); } @Override - protected Object wrappedMatchingParam(int matchingDocOrdinal) { + protected Object wrappedMatchingParam(int matchingDocOrdinal, DataSet> dataSet) { return new ValueWrapper<>( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @@ -559,7 +506,7 @@ protected String predicateNameInErrorMessage() { } @Nested - public static class ScaleCheckingIT extends AbstractPredicateScaleCheckingIT { + class ScaleCheckingIT extends AbstractPredicateScaleCheckingIT { private static final DataSet dataSet = new DataSet(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateMultivaluedIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateMultivaluedIT.java index c6087b3fb2d..8d2f93bc7e9 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateMultivaluedIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateMultivaluedIT.java @@ -19,22 +19,21 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class TermsPredicateMultivaluedIT { +class TermsPredicateMultivaluedIT { private static final List> types = new ArrayList<>(); private static final List> typeValuesSet = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); private static final String DOC_ID = "my_only_document"; @@ -49,18 +48,18 @@ public class TermsPredicateMultivaluedIT { types.add( type ); TypeValues typeValues = new TypeValues<>( type ); typeValuesSet.add( typeValues ); - parameters.add( new Object[] { typeValues } ); + parameters.add( Arguments.of( typeValues.values ) ); } } private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, types ) ).name( "simpleField" ); - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); indexer.add( DOC_ID, doc -> { @@ -71,19 +70,13 @@ public static void setup() { indexer.join(); } - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - private final TermsPredicateTestValues values; - - public TermsPredicateMultivaluedIT(TypeValues typeValues) { - this.values = typeValues.values; - } - - @Test - public void matchingAny_rightTerms() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void matchingAny_rightTerms(TermsPredicateTestValues values) { String path = index.binding().field.get( values.fieldType() ).relativeFieldName; for ( int i = 0; i < values.size(); i++ ) { F term = values.matchingArg( i ); @@ -92,8 +85,9 @@ public void matchingAny_rightTerms() { } } - @Test - public void matchingAny_wrongTerms() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void matchingAny_wrongTerms(TermsPredicateTestValues values) { String path = index.binding().field.get( values.fieldType() ).relativeFieldName; for ( int i = 0; i < values.nonMatchingArgsSize(); i++ ) { F term = values.nonMatchingArg( i ); @@ -102,8 +96,9 @@ public void matchingAny_wrongTerms() { } } - @Test - public void matchingAll_someTerms() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void matchingAll_someTerms(TermsPredicateTestValues values) { String path = index.binding().field.get( values.fieldType() ).relativeFieldName; F firstTerm = null; @@ -122,8 +117,9 @@ public void matchingAll_someTerms() { .hasDocRefHitsAnyOrder( index.typeName(), DOC_ID ); } - @Test - public void matchingAll_allTerms() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void matchingAll_allTerms(TermsPredicateTestValues values) { String path = index.binding().field.get( values.fieldType() ).relativeFieldName; F firstTerm = null; @@ -142,8 +138,9 @@ public void matchingAll_allTerms() { .hasDocRefHitsAnyOrder( index.typeName(), DOC_ID ); } - @Test - public void matchingAll_oneWrongTerm() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void matchingAll_oneWrongTerm(TermsPredicateTestValues values) { String path = index.binding().field.get( values.fieldType() ).relativeFieldName; F firstTerm = null; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateSpecificsIT.java index adde8163ea5..a1221e263f2 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/TermsPredicateSpecificsIT.java @@ -19,23 +19,23 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class TermsPredicateSpecificsIT { +class TermsPredicateSpecificsIT { // it should be more than the default max clause count of the boolean queries private static final int LOT_OF_TERMS_SIZE = 2000; private static final String DOC_ID = "id0"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private final List lotsOfTerms = new ArrayList<>(); @@ -49,8 +49,8 @@ public TermsPredicateSpecificsIT() { } } - @Before - public void before() { + @BeforeEach + void before() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); indexer.add( "id0", f -> { @@ -70,7 +70,7 @@ public void before() { } @Test - public void emptyTerms_matchingAny() { + void emptyTerms_matchingAny() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.query() @@ -81,7 +81,7 @@ public void emptyTerms_matchingAny() { } @Test - public void emptyTerms_matchingAll() { + void emptyTerms_matchingAll() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.query() @@ -92,7 +92,7 @@ public void emptyTerms_matchingAll() { } @Test - public void lotsOfTerms_matchingAny() { + void lotsOfTerms_matchingAny() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query().where( @@ -105,7 +105,7 @@ public void lotsOfTerms_matchingAny() { } @Test - public void analyzedField_termIsNotAnalyzed() { + void analyzedField_termIsNotAnalyzed() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query().where( @@ -123,7 +123,7 @@ public void analyzedField_termIsNotAnalyzed() { } @Test - public void normalizedField_termIsNotNormalized() { + void normalizedField_termIsNotNormalized() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query().where( @@ -146,7 +146,7 @@ public void normalizedField_termIsNotNormalized() { } @Test - public void lowercaseWhitespaceAnalyzedField_termIsNotNormalized() { + void lowercaseWhitespaceAnalyzedField_termIsNotNormalized() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query().where( diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/WildcardPredicateBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/WildcardPredicateBaseIT.java index b0866a961e5..2180360066b 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/WildcardPredicateBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/WildcardPredicateBaseIT.java @@ -12,20 +12,19 @@ import org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep; import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(NestedRunner.class) -public class WildcardPredicateBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class WildcardPredicateBaseIT { + //CHECKSTYLE:ON private static final List> supportedFieldTypes = new ArrayList<>(); private static final List> unsupportedFieldTypes = new ArrayList<>(); @@ -42,11 +41,11 @@ public class WildcardPredicateBaseIT { } } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( SingleFieldIT.index, MultiFieldIT.index, @@ -99,102 +98,75 @@ private static WildcardPredicateTestValues testValues(FieldTypeDescriptor { + class SingleFieldIT extends AbstractPredicateSingleFieldIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "singleField" ); private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "singleField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public SingleFieldIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.wildcard().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class MultiFieldIT extends AbstractPredicateMultiFieldIT { + class MultiFieldIT extends AbstractPredicateMultiFieldIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "multiField" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "multiField" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public MultiFieldIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override protected PredicateFinalStep predicateOnFieldAndField(SearchPredicateFactory f, String fieldPath, - String otherFieldPath, int matchingDocOrdinal) { + String otherFieldPath, int matchingDocOrdinal, DataSet dataSet) { return f.wildcard().field( fieldPath ).field( otherFieldPath ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override - protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal) { + protected PredicateFinalStep predicateOnFields(SearchPredicateFactory f, String[] fieldPaths, int matchingDocOrdinal, + DataSet dataSet) { return f.wildcard().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateOnFieldAndFields(SearchPredicateFactory f, String fieldPath, - String[] fieldPaths, int matchingDocOrdinal) { + String[] fieldPaths, int matchingDocOrdinal, DataSet dataSet) { return f.wildcard().field( fieldPath ).fields( fieldPaths ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - + class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldIT { private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "nesting" ); @@ -203,97 +175,100 @@ public static class InObjectFieldIT extends AbstractPredicateFieldInObjectFieldI SimpleMappedIndex.of( root -> new MissingFieldIndexBinding( root, supportedFieldTypes ) ) .name( "nesting_missingField" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( mainIndex, missingFieldIndex, dataSet ) ); + } } - public InObjectFieldIT(DataSet dataSet) { - super( mainIndex, missingFieldIndex, dataSet ); + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.wildcard().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } } @Nested - @RunWith(Parameterized.class) - public static class ScoreIT extends AbstractPredicateFieldScoreIT { + class ScoreIT extends AbstractPredicateFieldScoreIT { + private static final SimpleMappedIndex index = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "score" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { DataSet dataSet = new DataSet<>( testValues( fieldType ) ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( index, dataSet ) ); } } - private static final SimpleMappedIndex index = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "score" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public ScoreIT(DataSet dataSet) { - super( index, dataSet ); - } - @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.wildcard().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithConstantScore(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.wildcard().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore(); } @Override protected PredicateFinalStep predicateWithPredicateLevelBoost(SearchPredicateFactory f, String[] fieldPaths, - int matchingDocOrdinal, float predicateBoost) { + int matchingDocOrdinal, float predicateBoost, DataSet dataSet) { return f.wildcard().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) .boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithConstantScoreAndPredicateLevelBoost(SearchPredicateFactory f, - String[] fieldPaths, int matchingDocOrdinal, float predicateBoost) { + String[] fieldPaths, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.wildcard().fields( fieldPaths ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ) .constantScore().boost( predicateBoost ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoost(SearchPredicateFactory f, String fieldPath, - float fieldBoost, int matchingDocOrdinal) { + float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.wildcard().field( fieldPath ).boost( fieldBoost ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndConstantScore(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, DataSet dataSet) { return f.wildcard().field( fieldPath ).boost( fieldBoost ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).constantScore(); } @Override protected PredicateFinalStep predicateWithFieldLevelBoostAndPredicateLevelBoost(SearchPredicateFactory f, - String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost) { + String fieldPath, float fieldBoost, int matchingDocOrdinal, float predicateBoost, + DataSet dataSet) { return f.wildcard().field( fieldPath ).boost( fieldBoost ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ).boost( predicateBoost ); } } @Nested - public static class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { + class InvalidFieldIT extends AbstractPredicateInvalidFieldIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "invalidField" ); @@ -313,26 +288,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class UnsupportedTypeIT extends AbstractPredicateUnsupportedTypeIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, unsupportedFieldTypes ) ) .name( "unsupportedType" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : unsupportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public UnsupportedTypeIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -347,15 +316,7 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class SearchableIT extends AbstractPredicateSearchableIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class SearchableIT extends AbstractPredicateSearchableIT { private static final SimpleMappedIndex searchableYesIndex = SimpleMappedIndex.of( root -> new SearchableYesIndexBinding( root, supportedFieldTypes ) ) .name( "searchableYes" ); @@ -364,13 +325,15 @@ public static class SearchableIT extends AbstractPredicateSearchableIT { SimpleMappedIndex.of( root -> new SearchableNoIndexBinding( root, supportedFieldTypes ) ) .name( "searchableNo" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( searchableYesIndex, searchableNoIndex, fieldType ) ); + } } - public SearchableIT(FieldTypeDescriptor fieldType) { - super( searchableYesIndex, searchableNoIndex, fieldType ); + public static List params() { + return parameters; } @Override @@ -385,26 +348,20 @@ protected String predicateNameInErrorMessage() { } @Nested - @RunWith(Parameterized.class) - public static class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); - } - } - + class ArgumentCheckingIT extends AbstractPredicateArgumentCheckingIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "argumentChecking" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + parameters.add( Arguments.of( index, fieldType ) ); + } } - public ArgumentCheckingIT(FieldTypeDescriptor fieldType) { - super( index, fieldType ); + public static List params() { + return parameters; } @Override @@ -414,24 +371,8 @@ protected void tryPredicateWithNullMatchingParam(SearchPredicateFactory f, Strin } @Nested - @RunWith(Parameterized.class) - public static class TypeCheckingNoConversionIT + class TypeCheckingNoConversionIT extends AbstractPredicateTypeCheckingNoConversionIT { - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - DataSet dataSet = new DataSet<>( testValues( fieldType ) ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; - } - private static final SimpleMappedIndex index = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_main" ); @@ -448,18 +389,30 @@ public static List parameters() { SimpleMappedIndex.of( root -> new IncompatibleIndexBinding( root, supportedFieldTypes ) ) .name( "typeChecking_incompatible" ); - public TypeCheckingNoConversionIT(DataSet dataSet) { - super( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex, dataSet ); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { + DataSet dataSet = new DataSet<>( testValues( fieldType ) ); + dataSets.add( dataSet ); + parameters.add( Arguments.of( index, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, + incompatibleIndex, dataSet ) ); + } + } + + public static List params() { + return parameters; } @Override - protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal) { + protected PredicateFinalStep predicate(SearchPredicateFactory f, String fieldPath, int matchingDocOrdinal, + DataSet dataSet) { return f.wildcard().field( fieldPath ).matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } @Override protected PredicateFinalStep predicate(SearchPredicateFactory f, String field0Path, String field1Path, - int matchingDocOrdinal) { + int matchingDocOrdinal, DataSet dataSet) { return f.wildcard().field( field0Path ).field( field1Path ) .matching( dataSet.values.matchingArg( matchingDocOrdinal ) ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/WildcardPredicateSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/WildcardPredicateSpecificsIT.java index cd030ec6116..3a4d69ff1e3 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/WildcardPredicateSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/WildcardPredicateSpecificsIT.java @@ -18,18 +18,18 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.NormalizedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class WildcardPredicateSpecificsIT { +class WildcardPredicateSpecificsIT { private static final String DOCUMENT_1 = "document1"; private static final String DOCUMENT_2 = "document2"; @@ -57,15 +57,15 @@ public class WildcardPredicateSpecificsIT { private static final String TERM_MATCHING_PATTERN_2 = "iNTroSPEctiOn"; private static final String TERM_MATCHING_PATTERN_2_AND_3 = "Internationalization"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); private static final DataSet dataSet = new DataSet(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -75,7 +75,7 @@ public static void setup() { @Test @PortedFromSearch5(original = "org.hibernate.search.test.dsl.DSLTest.testWildcardQuery") - public void matchSingleToken() { + void matchSingleToken() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -93,7 +93,7 @@ public void matchSingleToken() { @Test @TestForIssue(jiraKey = "HSEARCH-3612") - public void normalizeMatchingExpression() { + void normalizeMatchingExpression() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().normalizedField.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -111,7 +111,7 @@ public void normalizeMatchingExpression() { @Test @TestForIssue(jiraKey = "HSEARCH-3844") // Used to throw NPE - public void nonAnalyzedField() { + void nonAnalyzedField() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().nonAnalyzedField.relativeFieldName; Function> createQuery = queryString -> scope.query() @@ -134,7 +134,7 @@ public void nonAnalyzedField() { } @Test - public void emptyString() { + void emptyString() { String absoluteFieldPath = index.binding().analyzedStringField1.relativeFieldName; assertThatQuery( index.query() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractCompositeProjectionFromAsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractCompositeProjectionFromAsIT.java index b47ec75258d..2957600d024 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractCompositeProjectionFromAsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractCompositeProjectionFromAsIT.java @@ -34,39 +34,39 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.LocalDateFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; import org.hibernate.search.util.impl.test.data.Pair; import org.hibernate.search.util.impl.test.data.Triplet; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; /** * Abstract base for tests of the from/as syntax of composite or object projections, * e.g. {@code f.composite().from( otherProjection1, otherProjection2 ).as( MyPair::new ) }. */ -@RunWith(NestedRunner.class) +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) public abstract class AbstractCompositeProjectionFromAsIT { + //CHECKSTYLE:ON - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); - private static final ProjectionRegistry projectionRegistryMock = Mockito.mock( ProjectionRegistry.class ); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); + private static final ProjectionRegistry projectionRegistryMock = Mockito.mock( ProjectionRegistry.class ); private final SimpleMappedIndex index; private final AbstractDataSet dataSet; @@ -76,11 +76,6 @@ public AbstractCompositeProjectionFromAsIT(SimpleMappedIndex index, AbstractD this.dataSet = dataSet; } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - protected abstract CompositeProjectionInnerStep startProjection(SearchProjectionFactory f); protected abstract CompositeProjectionInnerStep startProjectionForMulti(SearchProjectionFactory f); @@ -318,7 +313,7 @@ protected final Collection> expectedTransformedForMulti() { } @Nested - public class From1IT + class From1IT extends AbstractFromSpecificNumberIT, ValueWrapper> { @Override protected CompositeProjectionFrom1AsStep doFrom(SearchProjectionFactory f, @@ -344,7 +339,7 @@ protected ValueWrapper expectedTransformed(int docOrdinal, int inDocOrdi } @Nested - public class From2IT + class From2IT extends AbstractFromSpecificNumberIT, Pair> { @Override protected CompositeProjectionFrom2AsStep doFrom(SearchProjectionFactory f, @@ -374,7 +369,7 @@ protected Pair expectedTransformed(int docOrdinal, int inDocOrdi } @Nested - public class From3IT + class From3IT extends AbstractFromSpecificNumberIT, Triplet> { @Override @@ -408,7 +403,7 @@ protected Triplet expectedTransformed(int docOrdinal, } @Nested - public class From4IT + class From4IT extends AbstractFromAnyNumberIT { @Override protected CompositeProjectionFromAsStep doFrom(SearchProjectionFactory f, diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractEntityProjectionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractEntityProjectionIT.java index 16404ede14a..b2865193284 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractEntityProjectionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractEntityProjectionIT.java @@ -54,14 +54,16 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings("unchecked") // Mocking parameterized types public abstract class AbstractEntityProjectionIT { @@ -72,9 +74,6 @@ public abstract class AbstractEntityProjectionIT { protected static final ProjectionMappedTypeContext mainTypeContextMock = Mockito.mock( ProjectionMappedTypeContext.class ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - private final SimpleMappedIndex mainIndex; private final SimpleMappedIndex multiIndex1; private final SimpleMappedIndex multiIndex2; @@ -96,7 +95,7 @@ protected AbstractEntityProjectionIT(SimpleMappedIndex mainIndex, @Test @TestForIssue(jiraKey = "HSEARCH-3578") - public void entityLoading() { + void entityLoading() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); StubEntity doc1LoadedEntity = new StubEntity( doc1Reference ); @@ -141,7 +140,7 @@ public void entityLoading() { } @Test - public void entityLoading_timeout() { + void entityLoading_timeout() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); StubEntity doc1LoadedEntity = new StubEntity( doc1Reference ); @@ -187,7 +186,7 @@ public void entityLoading_timeout() { } @Test - public void noEntityLoading() { + void noEntityLoading() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = select( scope.query() ) @@ -202,7 +201,7 @@ public void noEntityLoading() { } @Test - public void entityLoading_callGetProjectionHitMapperEveryTime() { + void entityLoading_callGetProjectionHitMapperEveryTime() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); @@ -247,7 +246,7 @@ public void entityLoading_callGetProjectionHitMapperEveryTime() { @Test @TestForIssue(jiraKey = "HSEARCH-3349") - public void entityLoading_failed_skipHit() { + void entityLoading_failed_skipHit() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); StubEntity doc2LoadedObject = new StubEntity( doc2Reference ); @@ -280,7 +279,7 @@ public void entityLoading_failed_skipHit() { @Test @TestForIssue(jiraKey = "HSEARCH-4579") - public void noLoadingAvailable_noProjectionRegistryEntry_fails() { + void noLoadingAvailable_noProjectionRegistryEntry_fails() { ProjectionRegistry projectionRegistryMock = Mockito.mock( ProjectionRegistry.class ); SearchLoadingContext loadingContextMock = @@ -324,7 +323,7 @@ public void noLoadingAvailable_noProjectionRegistryEntry_fails() { @Test @TestForIssue(jiraKey = "HSEARCH-4579") - public void projectionRegistryFallback_withLoadingAvailable_doesNotCheckProjectionRegistry() { + void projectionRegistryFallback_withLoadingAvailable_doesNotCheckProjectionRegistry() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); StubEntity doc1LoadedEntity = new StubEntity( doc1Reference ); @@ -363,7 +362,7 @@ public void projectionRegistryFallback_withLoadingAvailable_doesNotCheckProjecti @Test @TestForIssue(jiraKey = "HSEARCH-4579") - public void projectionRegistryFallback_noLoadingAvailable_withProjectionRegistryEntry_usesProjectionRegistry() { + void projectionRegistryFallback_noLoadingAvailable_withProjectionRegistryEntry_usesProjectionRegistry() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); @@ -417,7 +416,7 @@ public void projectionRegistryFallback_noLoadingAvailable_withProjectionRegistry */ @Test @TestForIssue(jiraKey = "HSEARCH-4579") - public void projectionRegistryFallback_multiType() { + void projectionRegistryFallback_multiType() { DocumentReference type1Doc1Reference = reference( multiIndex1.typeName(), DOCUMENT_1_ID ); DocumentReference type1Doc2Reference = reference( multiIndex1.typeName(), DOCUMENT_2_ID ); DocumentReference type2Doc1Reference = reference( multiIndex2.typeName(), DOCUMENT_1_ID ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractEntityReferenceProjectionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractEntityReferenceProjectionIT.java index a21ffc532d6..50cf6437a72 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractEntityReferenceProjectionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractEntityReferenceProjectionIT.java @@ -28,14 +28,16 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.GenericStubMappingScope; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings("unchecked") // Mocking parameterized types public abstract class AbstractEntityReferenceProjectionIT { @@ -44,9 +46,6 @@ public abstract class AbstractEntityReferenceProjectionIT { private static final ProjectionMappedTypeContext mainTypeContextMock = Mockito.mock( ProjectionMappedTypeContext.class ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - private final StubMappedIndex mainIndex; protected AbstractEntityReferenceProjectionIT(StubMappedIndex mainIndex) { @@ -57,7 +56,7 @@ protected AbstractEntityReferenceProjectionIT(StubMappedIndex mainIndex) { SearchQuerySelectStep step); @Test - public void test() { + void test() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); EntityReference doc1EntityReference = StubEntity.reference( doc1Reference ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractProjectionInObjectProjectionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractProjectionInObjectProjectionIT.java index 05ef44253e1..472a3f8584a 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractProjectionInObjectProjectionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/AbstractProjectionInObjectProjectionIT.java @@ -32,7 +32,8 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; @@ -53,49 +54,41 @@ public abstract class AbstractProjectionInObjectProjectionIT mainIndex; - private final SimpleMappedIndex missingLevel1Index; - private final SimpleMappedIndex missingLevel1SingleValuedFieldIndex; - private final SimpleMappedIndex missingLevel2Index; - private final SimpleMappedIndex missingLevel2SingleValuedFieldIndex; - protected final DataSet dataSet; - private final RecursiveComparisonConfiguration recursiveComparisonConfig; + protected RecursiveComparisonConfiguration.Builder configureRecursiveComparison( + RecursiveComparisonConfiguration.Builder builder) { + return builder; + } - public AbstractProjectionInObjectProjectionIT(SimpleMappedIndex mainIndex, + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void objectOnLevel1AndObjectOnLevel2(SimpleMappedIndex mainIndex, SimpleMappedIndex missingLevel1Index, SimpleMappedIndex missingLevel1SingleValuedFieldIndex, SimpleMappedIndex missingLevel2Index, SimpleMappedIndex missingLevel2SingleValuedFieldIndex, DataSet dataSet) { - this.mainIndex = mainIndex; - this.missingLevel1Index = missingLevel1Index; - this.missingLevel1SingleValuedFieldIndex = missingLevel1SingleValuedFieldIndex; - this.missingLevel2Index = missingLevel2Index; - this.missingLevel2SingleValuedFieldIndex = missingLevel2SingleValuedFieldIndex; - this.dataSet = dataSet; - this.recursiveComparisonConfig = configureRecursiveComparison( RecursiveComparisonConfiguration.builder() ) + RecursiveComparisonConfiguration recursiveComparisonConfig = configureRecursiveComparison( + RecursiveComparisonConfiguration.builder() ) .build(); - } - - protected RecursiveComparisonConfiguration.Builder configureRecursiveComparison( - RecursiveComparisonConfiguration.Builder builder) { - return builder; - } - @Test - public void objectOnLevel1AndObjectOnLevel2() { assertThatQuery( mainIndex.query() .select( f -> f.composite() .from( f.id( String.class ), - f.object( level1Path() ) + f.object( level1Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, level1SingleValuedFieldPath() ), - multiValuedProjection( f, level1MultiValuedFieldPath() ), - f.object( level2Path() ) + singleValuedProjection( f, level1SingleValuedFieldPath( mainIndex, + dataSet + ), dataSet ), + multiValuedProjection( f, level1MultiValuedFieldPath( mainIndex, + dataSet + ), dataSet ), + f.object( level2Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, level2SingleValuedFieldPath() ), - multiValuedProjection( f, level2MultiValuedFieldPath() ) + singleValuedProjection( f, level2SingleValuedFieldPath( + mainIndex, dataSet ), dataSet ), + multiValuedProjection( f, level2MultiValuedFieldPath( + mainIndex, dataSet ), dataSet ) ) .as( ObjectDto::new ) .multi() @@ -140,7 +133,7 @@ public void objectOnLevel1AndObjectOnLevel2() { ) ) ) - ) ), + ), dataSet ), hit( SINGLE_VALUED_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectDto<>( dataSet.values.projectedValue( 0 ), @@ -152,7 +145,7 @@ public void objectOnLevel1AndObjectOnLevel2() { ) ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectDto<>( dataSet.values.projectedValue( 0 ), @@ -168,18 +161,18 @@ public void objectOnLevel1AndObjectOnLevel2() { ) ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectDto<>( null, Collections.emptyList(), Collections.emptyList() ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_NULL_OBJECT_DOCUMENT_ID, listMaybeWithNull( (Level1ObjectDto

) null - ) ), - hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, Collections.emptyList() ), + ), dataSet ), + hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, Collections.emptyList(), dataSet ), hit( LEVEL2_SINGLE_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectDto<>( null, @@ -201,7 +194,7 @@ public void objectOnLevel1AndObjectOnLevel2() { ) ) ) - ) ), + ), dataSet ), hit( LEVEL2_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectDto<>( null, @@ -223,7 +216,7 @@ public void objectOnLevel1AndObjectOnLevel2() { ) ) ) - ) ), + ), dataSet ), hit( LEVEL2_NO_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectDto<>( null, @@ -235,20 +228,33 @@ public void objectOnLevel1AndObjectOnLevel2() { Collections.emptyList(), Collections.emptyList() ) - ) ) + ), dataSet ) ); } - @Test - public void objectOnLevel1AndNoLevel2() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void objectOnLevel1AndNoLevel2(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingLevel1Index, + SimpleMappedIndex missingLevel1SingleValuedFieldIndex, + SimpleMappedIndex missingLevel2Index, + SimpleMappedIndex missingLevel2SingleValuedFieldIndex, + DataSet dataSet) { + RecursiveComparisonConfiguration recursiveComparisonConfig = configureRecursiveComparison( + RecursiveComparisonConfiguration.builder() ) + .build(); assertThatQuery( mainIndex.query() .select( f -> f.composite() .from( f.id( String.class ), - f.object( level1Path() ) + f.object( level1Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, level1SingleValuedFieldPath() ), - multiValuedProjection( f, level1MultiValuedFieldPath() ) + singleValuedProjection( f, level1SingleValuedFieldPath( mainIndex, + dataSet + ), dataSet ), + multiValuedProjection( f, level1MultiValuedFieldPath( mainIndex, + dataSet + ), dataSet ) ) .as( ObjectDto::new ) .multi() @@ -268,29 +274,29 @@ public void objectOnLevel1AndNoLevel2() { dataSet.values.projectedValue( 9 ), dataSet.values.projectedValues( 10, 11 ) ) - ) ), + ), dataSet ), hit( SINGLE_VALUED_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( dataSet.values.projectedValue( 0 ), dataSet.values.projectedValues( 1 ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_OBJECT_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( dataSet.values.projectedValue( 0 ), dataSet.values.projectedValues( 1, 2 ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( null, Collections.emptyList() ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_NULL_OBJECT_DOCUMENT_ID, listMaybeWithNull( (ObjectDto

) null - ) ), - hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, Collections.emptyList() ), + ), dataSet ), + hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, Collections.emptyList(), dataSet ), hit( LEVEL2_SINGLE_OBJECT_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( null, @@ -300,7 +306,7 @@ public void objectOnLevel1AndNoLevel2() { null, Collections.emptyList() ) - ) ), + ), dataSet ), hit( LEVEL2_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( null, @@ -310,7 +316,7 @@ public void objectOnLevel1AndNoLevel2() { null, Collections.emptyList() ) - ) ), + ), dataSet ), hit( LEVEL2_NO_OBJECT_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( null, @@ -320,24 +326,39 @@ public void objectOnLevel1AndNoLevel2() { null, Collections.emptyList() ) - ) ) + ), dataSet ) ); } - @Test - public void objectOnLevel1AndFlattenedLevel2() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void objectOnLevel1AndFlattenedLevel2(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingLevel1Index, + SimpleMappedIndex missingLevel1SingleValuedFieldIndex, + SimpleMappedIndex missingLevel2Index, + SimpleMappedIndex missingLevel2SingleValuedFieldIndex, + DataSet dataSet) { + RecursiveComparisonConfiguration recursiveComparisonConfig = configureRecursiveComparison( + RecursiveComparisonConfiguration.builder() ) + .build(); assertThatQuery( mainIndex.query() .select( f -> f.composite() .from( f.id( String.class ), - f.object( level1Path() ) + f.object( level1Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, level1SingleValuedFieldPath() ), - multiValuedProjection( f, level1MultiValuedFieldPath() ), + singleValuedProjection( f, level1SingleValuedFieldPath( mainIndex, + dataSet + ), dataSet ), + multiValuedProjection( f, level1MultiValuedFieldPath( mainIndex, + dataSet + ), dataSet ), f.composite() .from( - multiValuedProjection( f, level2SingleValuedFieldPath() ), - multiValuedProjection( f, level2MultiValuedFieldPath() ) + multiValuedProjection( f, level2SingleValuedFieldPath( + mainIndex, dataSet ), dataSet ), + multiValuedProjection( f, level2MultiValuedFieldPath( + mainIndex, dataSet ), dataSet ) ) .as( FlattenedObjectDto::new ) ) @@ -367,7 +388,7 @@ public void objectOnLevel1AndFlattenedLevel2() { dataSet.values.projectedValues( 13, 14, 16, 17 ) ) ) - ) ), + ), dataSet ), hit( SINGLE_VALUED_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectWithFlattenedLevel2Dto<>( dataSet.values.projectedValue( 0 ), @@ -377,7 +398,7 @@ public void objectOnLevel1AndFlattenedLevel2() { dataSet.values.projectedValues( 3 ) ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectWithFlattenedLevel2Dto<>( dataSet.values.projectedValue( 0 ), @@ -387,7 +408,7 @@ public void objectOnLevel1AndFlattenedLevel2() { dataSet.values.projectedValues( 4, 5, 7, 8 ) ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectWithFlattenedLevel2Dto<>( null, @@ -397,11 +418,11 @@ public void objectOnLevel1AndFlattenedLevel2() { Collections.emptyList() ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_NULL_OBJECT_DOCUMENT_ID, listMaybeWithNull( (Level1ObjectWithFlattenedLevel2Dto

) null - ) ), - hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, Collections.emptyList() ), + ), dataSet ), + hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, Collections.emptyList(), dataSet ), hit( LEVEL2_SINGLE_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectWithFlattenedLevel2Dto<>( null, @@ -419,7 +440,7 @@ public void objectOnLevel1AndFlattenedLevel2() { dataSet.values.projectedValues( 4, 5 ) ) ) - ) ), + ), dataSet ), hit( LEVEL2_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectWithFlattenedLevel2Dto<>( null, @@ -437,7 +458,7 @@ public void objectOnLevel1AndFlattenedLevel2() { Collections.emptyList() ) ) - ) ), + ), dataSet ), hit( LEVEL2_NO_OBJECT_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectWithFlattenedLevel2Dto<>( null, @@ -455,20 +476,31 @@ public void objectOnLevel1AndFlattenedLevel2() { Collections.emptyList() ) ) - ) ) + ), dataSet ) ); } - @Test - public void objectOnSingleValuedLevel1AndNoLevel2() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void objectOnSingleValuedLevel1AndNoLevel2(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingLevel1Index, + SimpleMappedIndex missingLevel1SingleValuedFieldIndex, + SimpleMappedIndex missingLevel2Index, + SimpleMappedIndex missingLevel2SingleValuedFieldIndex, + DataSet dataSet) { + RecursiveComparisonConfiguration recursiveComparisonConfig = configureRecursiveComparison( + RecursiveComparisonConfiguration.builder() ) + .build(); assertThatQuery( mainIndex.query() .select( f -> f.composite() .from( f.id( String.class ), - f.object( singleValuedLevel1Path() ) + f.object( singleValuedLevel1Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, singleValuedLevel1SingleValuedFieldPath() ), - multiValuedProjection( f, singleValuedLevel1MultiValuedFieldPath() ) + singleValuedProjection( f, singleValuedLevel1SingleValuedFieldPath( + mainIndex, dataSet ), dataSet ), + multiValuedProjection( f, singleValuedLevel1MultiValuedFieldPath( + mainIndex, dataSet ), dataSet ) ) .as( ObjectDto::new ) ) @@ -480,41 +512,55 @@ public void objectOnSingleValuedLevel1AndNoLevel2() { hit( FULL_DOCUMENT_ID, new ObjectDto<>( dataSet.values.projectedValue( 18 ), dataSet.values.projectedValues( 19, 20 ) - ) ), + ), dataSet ), hit( SINGLE_VALUED_DOCUMENT_ID, new ObjectDto<>( dataSet.values.projectedValue( 4 ), dataSet.values.projectedValues( 5 ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_OBJECT_DOCUMENT_ID, new ObjectDto<>( dataSet.values.projectedValue( 9 ), dataSet.values.projectedValues( 10, 11 ) - ) ), - hit( LEVEL1_SINGLE_NULL_OBJECT_DOCUMENT_ID, null ), + ), dataSet ), + hit( LEVEL1_SINGLE_NULL_OBJECT_DOCUMENT_ID, null, dataSet ), hit( LEVEL1_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, TckConfiguration.get().getBackendFeatures() .projectionPreservesEmptySingleValuedObject( dataSet.singleValuedObjectStructure ) ? new ObjectDto<>( null, Collections.emptyList() ) - : null + : null, + dataSet ), - hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, null ), - hit( LEVEL2_SINGLE_OBJECT_DOCUMENT_ID, null ), - hit( LEVEL2_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, null ), - hit( LEVEL2_NO_OBJECT_DOCUMENT_ID, null ) + hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, null, dataSet ), + hit( LEVEL2_SINGLE_OBJECT_DOCUMENT_ID, null, dataSet ), + hit( LEVEL2_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, null, dataSet ), + hit( LEVEL2_NO_OBJECT_DOCUMENT_ID, null, dataSet ) ); } - @Test - public void noLevel1AndObjectOnLevel2() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void noLevel1AndObjectOnLevel2(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingLevel1Index, + SimpleMappedIndex missingLevel1SingleValuedFieldIndex, + SimpleMappedIndex missingLevel2Index, + SimpleMappedIndex missingLevel2SingleValuedFieldIndex, + DataSet dataSet) { + RecursiveComparisonConfiguration recursiveComparisonConfig = configureRecursiveComparison( + RecursiveComparisonConfiguration.builder() ) + .build(); assertThatQuery( mainIndex.query() .select( f -> f.composite() .from( f.id( String.class ), - f.object( level2Path() ) + f.object( level2Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, level2SingleValuedFieldPath() ), - multiValuedProjection( f, level2MultiValuedFieldPath() ) + singleValuedProjection( f, level2SingleValuedFieldPath( mainIndex, + dataSet + ), dataSet ), + multiValuedProjection( f, level2MultiValuedFieldPath( mainIndex, + dataSet + ), dataSet ) ) .as( ObjectDto::new ) .multi() @@ -543,13 +589,13 @@ public void noLevel1AndObjectOnLevel2() { dataSet.values.projectedValue( 15 ), dataSet.values.projectedValues( 16, 17 ) ) - ) ), + ), dataSet ), hit( SINGLE_VALUED_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( dataSet.values.projectedValue( 2 ), dataSet.values.projectedValues( 3 ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_OBJECT_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( dataSet.values.projectedValue( 3 ), @@ -559,10 +605,10 @@ public void noLevel1AndObjectOnLevel2() { dataSet.values.projectedValue( 6 ), dataSet.values.projectedValues( 7, 8 ) ) - ) ), - hit( LEVEL1_SINGLE_NULL_OBJECT_DOCUMENT_ID, Collections.emptyList() ), - hit( LEVEL1_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, Collections.emptyList() ), - hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, Collections.emptyList() ), + ), dataSet ), + hit( LEVEL1_SINGLE_NULL_OBJECT_DOCUMENT_ID, Collections.emptyList(), dataSet ), + hit( LEVEL1_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, Collections.emptyList(), dataSet ), + hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, Collections.emptyList(), dataSet ), hit( LEVEL2_SINGLE_OBJECT_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( dataSet.values.projectedValue( 0 ), @@ -572,7 +618,7 @@ public void noLevel1AndObjectOnLevel2() { dataSet.values.projectedValue( 3 ), dataSet.values.projectedValues( 4, 5 ) ) - ) ), + ), dataSet ), hit( LEVEL2_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, listMaybeWithNull( new ObjectDto<>( null, @@ -582,25 +628,40 @@ public void noLevel1AndObjectOnLevel2() { null, Collections.emptyList() ) - ) ), - hit( LEVEL2_NO_OBJECT_DOCUMENT_ID, Collections.emptyList() ) + ), dataSet ), + hit( LEVEL2_NO_OBJECT_DOCUMENT_ID, Collections.emptyList(), dataSet ) ); } - @Test - public void flattenedLevel1AndObjectOnLevel2() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void flattenedLevel1AndObjectOnLevel2(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingLevel1Index, + SimpleMappedIndex missingLevel1SingleValuedFieldIndex, + SimpleMappedIndex missingLevel2Index, + SimpleMappedIndex missingLevel2SingleValuedFieldIndex, + DataSet dataSet) { + RecursiveComparisonConfiguration recursiveComparisonConfig = configureRecursiveComparison( + RecursiveComparisonConfiguration.builder() ) + .build(); assertThatQuery( mainIndex.query() .select( f -> f.composite() .from( f.id( String.class ), f.composite() .from( - multiValuedProjection( f, level1SingleValuedFieldPath() ), - multiValuedProjection( f, level1MultiValuedFieldPath() ), - f.object( level2Path() ) + multiValuedProjection( f, level1SingleValuedFieldPath( mainIndex, + dataSet + ), dataSet ), + multiValuedProjection( f, level1MultiValuedFieldPath( mainIndex, + dataSet + ), dataSet ), + f.object( level2Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, level2SingleValuedFieldPath() ), - multiValuedProjection( f, level2MultiValuedFieldPath() ) + singleValuedProjection( f, level2SingleValuedFieldPath( + mainIndex, dataSet ), dataSet ), + multiValuedProjection( f, level2MultiValuedFieldPath( + mainIndex, dataSet ), dataSet ) ) .as( ObjectDto::new ) .multi() @@ -635,7 +696,7 @@ public void flattenedLevel1AndObjectOnLevel2() { dataSet.values.projectedValues( 16, 17 ) ) ) - ) ), + ), dataSet ), hit( SINGLE_VALUED_DOCUMENT_ID, new FlattenedLevel1ObjectDto<>( dataSet.values.projectedValues( 0 ), dataSet.values.projectedValues( 1 ), @@ -645,7 +706,7 @@ public void flattenedLevel1AndObjectOnLevel2() { dataSet.values.projectedValues( 3 ) ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_OBJECT_DOCUMENT_ID, new FlattenedLevel1ObjectDto<>( dataSet.values.projectedValues( 0 ), dataSet.values.projectedValues( 1, 2 ), @@ -659,22 +720,22 @@ public void flattenedLevel1AndObjectOnLevel2() { dataSet.values.projectedValues( 7, 8 ) ) ) - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_NULL_OBJECT_DOCUMENT_ID, new FlattenedLevel1ObjectDto<>( Collections.emptyList(), Collections.emptyList(), Collections.emptyList() - ) ), + ), dataSet ), hit( LEVEL1_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, new FlattenedLevel1ObjectDto<>( Collections.emptyList(), Collections.emptyList(), Collections.emptyList() - ) ), + ), dataSet ), hit( LEVEL1_NO_OBJECT_DOCUMENT_ID, new FlattenedLevel1ObjectDto<>( Collections.emptyList(), Collections.emptyList(), Collections.emptyList() - ) ), + ), dataSet ), hit( LEVEL2_SINGLE_OBJECT_DOCUMENT_ID, new FlattenedLevel1ObjectDto<>( Collections.emptyList(), Collections.emptyList(), @@ -688,7 +749,7 @@ public void flattenedLevel1AndObjectOnLevel2() { dataSet.values.projectedValues( 4, 5 ) ) ) - ) ), + ), dataSet ), hit( LEVEL2_SINGLE_EMPTY_OBJECT_DOCUMENT_ID, new FlattenedLevel1ObjectDto<>( Collections.emptyList(), Collections.emptyList(), @@ -702,23 +763,31 @@ public void flattenedLevel1AndObjectOnLevel2() { Collections.emptyList() ) ) - ) ), + ), dataSet ), hit( LEVEL2_NO_OBJECT_DOCUMENT_ID, new FlattenedLevel1ObjectDto<>( Collections.emptyList(), Collections.emptyList(), Collections.emptyList() - ) ) + ), dataSet ) ); } - @Test - public void fieldOutsideObjectFieldTree() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void fieldOutsideObjectFieldTree(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingLevel1Index, + SimpleMappedIndex missingLevel1SingleValuedFieldIndex, + SimpleMappedIndex missingLevel2Index, + SimpleMappedIndex missingLevel2SingleValuedFieldIndex, + DataSet dataSet) { assertThatThrownBy( () -> mainIndex.query() - .select( f -> f.object( level2Path() ) + .select( f -> f.object( level2Path( mainIndex, dataSet ) ) .from( // This is incorrect: the inner projection uses fields from "level1", // which won't be present in "level1.level2". - singleValuedProjection( f, level1SingleValuedFieldPath() ) + singleValuedProjection( f, level1SingleValuedFieldPath( mainIndex, dataSet ), + dataSet + ) ) .asList() .multi() ) @@ -727,27 +796,43 @@ public void fieldOutsideObjectFieldTree() { .toQuery() ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( - "Invalid context for projection on field '" + level1SingleValuedFieldPath() + "'", - "the surrounding projection is executed for each object in field '" + level2Path() + "'," - + " which is not a parent of field '" + level1SingleValuedFieldPath() + "'", + "Invalid context for projection on field '" + level1SingleValuedFieldPath( mainIndex, dataSet ) + "'", + "the surrounding projection is executed for each object in field '" + level2Path( mainIndex, + dataSet + ) + "'," + + " which is not a parent of field '" + level1SingleValuedFieldPath( mainIndex, + dataSet + ) + "'", "Check the structure of your projections" ); } - @Test - public void singleValuedField_effectivelyMultiValuedInContext() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void singleValuedField_effectivelyMultiValuedInContext(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingLevel1Index, + SimpleMappedIndex missingLevel1SingleValuedFieldIndex, + SimpleMappedIndex missingLevel2Index, + SimpleMappedIndex missingLevel2SingleValuedFieldIndex, + DataSet dataSet) { assertThatThrownBy( () -> mainIndex.query() - .select( f -> f.object( level1Path() ) + .select( f -> f.object( level1Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, level1SingleValuedFieldPath() ), - multiValuedProjection( f, level1MultiValuedFieldPath() ), + singleValuedProjection( f, level1SingleValuedFieldPath( mainIndex, dataSet ), + dataSet + ), + multiValuedProjection( f, level1MultiValuedFieldPath( mainIndex, dataSet ), + dataSet + ), f.composite() .from( // This is incorrect: we don't use object( "level1.level2" ), // so this field is multi-valued, because it's collected // for each "level1" object, and "level1.level2" is multi-valued. - singleValuedProjection( f, level2SingleValuedFieldPath() ), - multiValuedProjection( f, level2MultiValuedFieldPath() ) + singleValuedProjection( f, level2SingleValuedFieldPath( + mainIndex, dataSet ), dataSet ), + multiValuedProjection( f, level2MultiValuedFieldPath( + mainIndex, dataSet ), dataSet ) ) .asList() ) @@ -758,18 +843,32 @@ public void singleValuedField_effectivelyMultiValuedInContext() { .toQuery() ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( - "Invalid cardinality for projection on field '" + level2SingleValuedFieldPath() + "'", + "Invalid cardinality for projection on field '" + level2SingleValuedFieldPath( mainIndex, + dataSet + ) + "'", "the projection is single-valued, but this field is effectively multi-valued in this context", - "because parent object field '" + level2Path() + "' is multi-valued", - "call '.multi()' when you create the projection on field '" + level2SingleValuedFieldPath() + "'", + "because parent object field '" + level2Path( mainIndex, dataSet ) + "' is multi-valued", + "call '.multi()' when you create the projection on field '" + level2SingleValuedFieldPath( + mainIndex, dataSet ) + "'", "or wrap that projection in an object projection like this:" - + " 'f.object(\"" + level2Path() + "\").from().as(...).multi()'." + + " 'f.object(\"" + level2Path( mainIndex, dataSet ) + "\").from().as(...).multi()'." ); } - @Test - public void missingFields() { + @ParameterizedTest(name = "{5}") + @MethodSource("params") + void missingFields(SimpleMappedIndex mainIndex, + SimpleMappedIndex missingLevel1Index, + SimpleMappedIndex missingLevel1SingleValuedFieldIndex, + SimpleMappedIndex missingLevel2Index, + SimpleMappedIndex missingLevel2SingleValuedFieldIndex, + DataSet dataSet) { + RecursiveComparisonConfiguration recursiveComparisonConfig = configureRecursiveComparison( + RecursiveComparisonConfiguration.builder() ) + .build(); StubMappingScope scope = mainIndex.createScope( missingLevel1Index, missingLevel1SingleValuedFieldIndex, missingLevel2Index, missingLevel2SingleValuedFieldIndex ); @@ -777,14 +876,20 @@ public void missingFields() { .select( f -> f.composite() .from( f.id( String.class ), - f.object( level1Path() ) + f.object( level1Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, level1SingleValuedFieldPath() ), - multiValuedProjection( f, level1MultiValuedFieldPath() ), - f.object( level2Path() ) + singleValuedProjection( f, level1SingleValuedFieldPath( mainIndex, + dataSet + ), dataSet ), + multiValuedProjection( f, level1MultiValuedFieldPath( mainIndex, + dataSet + ), dataSet ), + f.object( level2Path( mainIndex, dataSet ) ) .from( - singleValuedProjection( f, level2SingleValuedFieldPath() ), - multiValuedProjection( f, level2MultiValuedFieldPath() ) + singleValuedProjection( f, level2SingleValuedFieldPath( + mainIndex, dataSet ), dataSet ), + multiValuedProjection( f, level2MultiValuedFieldPath( + mainIndex, dataSet ), dataSet ) ) .as( ObjectDto::new ) .multi() @@ -797,7 +902,7 @@ public void missingFields() { .routing( dataSet.routingKey ) ) .hits().asIs().usingRecursiveFieldByFieldElementComparator( recursiveComparisonConfig ) .contains( - hit( MISSING_LEVEL1_DOCUMENT_ID, Collections.emptyList() ), + hit( MISSING_LEVEL1_DOCUMENT_ID, Collections.emptyList(), dataSet ), hit( MISSING_LEVEL1_SINGLE_VALUED_FIELD_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectDto<>( null, @@ -827,7 +932,7 @@ public void missingFields() { ) ) ) - ) ), + ), dataSet ), hit( MISSING_LEVEL2_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectDto<>( dataSet.values.projectedValue( 0 ), @@ -839,7 +944,7 @@ public void missingFields() { dataSet.values.projectedValues( 4, 5 ), Collections.emptyList() ) - ) ), + ), dataSet ), hit( MISSING_LEVEL2_SINGLE_VALUED_FIELD_DOCUMENT_ID, listMaybeWithNull( new Level1ObjectDto<>( dataSet.values.projectedValue( 0 ), @@ -869,7 +974,7 @@ public void missingFields() { ) ) ) - ) ) + ), dataSet ) ); } @@ -883,56 +988,60 @@ private static List listMaybeWithNull(T... values) { return list; } - private IdAndObjectDto hit(String docIdConstant, T object) { + private IdAndObjectDto hit(String docIdConstant, T object, + DataSet dataSet) { return new IdAndObjectDto<>( dataSet.docId( docIdConstant ), object ); } - private String level1Path() { + private String level1Path(SimpleMappedIndex mainIndex, DataSet dataSet) { return mainIndex.binding().level1( dataSet.multiValuedObjectStructure ).absolutePath; } - private String level1SingleValuedFieldPath() { + private String level1SingleValuedFieldPath(SimpleMappedIndex mainIndex, DataSet dataSet) { return mainIndex.binding().level1( dataSet.multiValuedObjectStructure ) .singleValuedFieldAbsolutePath( dataSet.fieldType ); } - private String level1MultiValuedFieldPath() { + private String level1MultiValuedFieldPath(SimpleMappedIndex mainIndex, DataSet dataSet) { return mainIndex.binding().level1( dataSet.multiValuedObjectStructure ) .multiValuedFieldAbsolutePath( dataSet.fieldType ); } - private String singleValuedLevel1Path() { + private String singleValuedLevel1Path(SimpleMappedIndex mainIndex, DataSet dataSet) { return mainIndex.binding().singleValuedLevel1( dataSet.singleValuedObjectStructure ).absolutePath; } - private String singleValuedLevel1SingleValuedFieldPath() { + private String singleValuedLevel1SingleValuedFieldPath(SimpleMappedIndex mainIndex, + DataSet dataSet) { return mainIndex.binding().singleValuedLevel1( dataSet.singleValuedObjectStructure ) .singleValuedFieldAbsolutePath( dataSet.fieldType ); } - private String singleValuedLevel1MultiValuedFieldPath() { + private String singleValuedLevel1MultiValuedFieldPath(SimpleMappedIndex mainIndex, DataSet dataSet) { return mainIndex.binding().singleValuedLevel1( dataSet.singleValuedObjectStructure ) .multiValuedFieldAbsolutePath( dataSet.fieldType ); } - private String level2Path() { + private String level2Path(SimpleMappedIndex mainIndex, DataSet dataSet) { return mainIndex.binding().level1( dataSet.multiValuedObjectStructure ).level2.absolutePath; } - private String level2SingleValuedFieldPath() { + private String level2SingleValuedFieldPath(SimpleMappedIndex mainIndex, DataSet dataSet) { return mainIndex.binding().level1( dataSet.multiValuedObjectStructure ).level2 .singleValuedFieldAbsolutePath( dataSet.fieldType ); } - private String level2MultiValuedFieldPath() { + private String level2MultiValuedFieldPath(SimpleMappedIndex mainIndex, DataSet dataSet) { return mainIndex.binding().level1( dataSet.multiValuedObjectStructure ).level2 .multiValuedFieldAbsolutePath( dataSet.fieldType ); } - protected abstract ProjectionFinalStep

singleValuedProjection(SearchProjectionFactory f, String absoluteFieldPath); + protected abstract ProjectionFinalStep

singleValuedProjection(SearchProjectionFactory f, String absoluteFieldPath, + DataSet dataSet); protected abstract ProjectionFinalStep> multiValuedProjection(SearchProjectionFactory f, - String absoluteFieldPath); + String absoluteFieldPath, + DataSet dataSet); public static final class DataSet> extends AbstractPerFieldTypeProjectionDataSet { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/CompositeProjectionBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/CompositeProjectionBaseIT.java index 1481c2887e9..6b56daa8a00 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/CompositeProjectionBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/CompositeProjectionBaseIT.java @@ -14,25 +14,24 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.search.projection.dsl.CompositeProjectionInnerStep; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; -@RunWith(NestedRunner.class) -public class CompositeProjectionBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class CompositeProjectionBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( FromAsIT.index ).setup(); BulkIndexer fromAsIndexer = FromAsIT.index.bulkIndexer(); @@ -41,11 +40,6 @@ public static void setup() { fromAsIndexer.join(); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - /** * Tests composite projections created through the multi-step DSL, * e.g. {@code f.composite().from( otherProjection1, otherProjection2 ).as( MyPair::new ) }, @@ -54,7 +48,7 @@ public void takariCpSuiteWorkaround() { * which is tested in {@link CompositeProjectionSingleStepIT}. */ @Nested - public static class FromAsIT extends AbstractCompositeProjectionFromAsIT { + class FromAsIT extends AbstractCompositeProjectionFromAsIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "fromAs" ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/CompositeProjectionSingleStepIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/CompositeProjectionSingleStepIT.java index d8ec2660a7d..8011af9aa71 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/CompositeProjectionSingleStepIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/CompositeProjectionSingleStepIT.java @@ -22,13 +22,13 @@ import org.hibernate.search.engine.backend.types.dsl.StandardIndexFieldTypeOptionsStep; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.StandardFieldMapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests composite projections created through the single-step DSL, @@ -38,7 +38,7 @@ * which is tested in {@link AbstractCompositeProjectionFromAsIT}. */ @SuppressWarnings("deprecation") -public class CompositeProjectionSingleStepIT { +class CompositeProjectionSingleStepIT { private static final String DOCUMENT_1 = "1"; private static final String DOCUMENT_2 = "2"; @@ -56,20 +56,20 @@ public class CompositeProjectionSingleStepIT { private static final String AUTHOR_AVENUE_OF_MYSTERIES = "John Irving"; private static final LocalDate RELEASE_DATE_AVENUE_OF_MYSTERIES = LocalDate.of( 2015, 4, 7 ); - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void compositeList_fromSearchProjectionObjects() { + void compositeList_fromSearchProjectionObjects() { StubMappingScope scope = index.createScope(); SearchQuery> query = scope.query() @@ -92,7 +92,7 @@ public void compositeList_fromSearchProjectionObjects() { } @Test - public void compositeList_fromTerminalContexts() { + void compositeList_fromTerminalContexts() { StubMappingScope scope = index.createScope(); SearchQuery> query = scope.query() @@ -115,7 +115,7 @@ public void compositeList_fromTerminalContexts() { } @Test - public void compositeList_transformer_fromSearchProjectionObjects() { + void compositeList_transformer_fromSearchProjectionObjects() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -139,7 +139,7 @@ public void compositeList_transformer_fromSearchProjectionObjects() { } @Test - public void compositeList_transformer_fromTerminalContext() { + void compositeList_transformer_fromTerminalContext() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -163,7 +163,7 @@ public void compositeList_transformer_fromTerminalContext() { } @Test - public void compositeFunction_fromSearchProjectionObjects() { + void compositeFunction_fromSearchProjectionObjects() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -183,7 +183,7 @@ public void compositeFunction_fromSearchProjectionObjects() { } @Test - public void compositeFunction_fromTerminalContext() { + void compositeFunction_fromTerminalContext() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -203,7 +203,7 @@ public void compositeFunction_fromTerminalContext() { } @Test - public void compositeBiFunction_fromSearchProjectionObjects() { + void compositeBiFunction_fromSearchProjectionObjects() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -227,7 +227,7 @@ public void compositeBiFunction_fromSearchProjectionObjects() { } @Test - public void compositeBiFunction_fromTerminalContexts() { + void compositeBiFunction_fromTerminalContexts() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -251,7 +251,7 @@ public void compositeBiFunction_fromTerminalContexts() { } @Test - public void compositeTriFunction_fromSearchProjectionObjects() { + void compositeTriFunction_fromSearchProjectionObjects() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -279,7 +279,7 @@ public void compositeTriFunction_fromSearchProjectionObjects() { } @Test - public void compositeTriFunction_fromTerminalContexts() { + void compositeTriFunction_fromTerminalContexts() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -307,7 +307,7 @@ public void compositeTriFunction_fromTerminalContexts() { } @Test - public void nestedComposite() { + void nestedComposite() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionBaseIT.java index f50baff8a51..1719a33ec4b 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionBaseIT.java @@ -17,33 +17,32 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.assertion.TestComparators; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; -@RunWith(NestedRunner.class) -public class DistanceProjectionBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class DistanceProjectionBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static DistanceProjectionTestValues testValues() { return new DistanceProjectionTestValues(); } - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( InObjectProjectionIT.mainIndex, InObjectProjectionIT.missingLevel1Index, InObjectProjectionIT.missingLevel1SingleValuedFieldIndex, @@ -69,36 +68,11 @@ public static void setup() { compositeForEachMissingLevel2SingleValuedFieldIndexer ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class InObjectProjectionIT + class InObjectProjectionIT extends AbstractProjectionInObjectProjectionIT { private static final List> supportedFieldTypes = Arrays.asList( GeoPointFieldTypeDescriptor.INSTANCE ); - private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); - static { - for ( ObjectStructure singleValuedObjectStructure : new ObjectStructure[] { - ObjectStructure.FLATTENED, - ObjectStructure.NESTED } ) { - ObjectStructure multiValuedObjectStructure = - ObjectStructure.NESTED.equals( singleValuedObjectStructure ) - || TckConfiguration.get().getBackendFeatures() - .reliesOnNestedDocumentsForMultiValuedObjectProjection() - ? ObjectStructure.NESTED - : ObjectStructure.FLATTENED; - DataSet dataSet = new DataSet<>( testValues(), - singleValuedObjectStructure, multiValuedObjectStructure ); - dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); - } - } - private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) .name( "main" ); @@ -115,15 +89,30 @@ public static class InObjectProjectionIT SimpleMappedIndex.of( root -> new MissingLevel2SingleValuedFieldIndexBinding( root, supportedFieldTypes ) ) .name( "missingLevel2Field1" ); - @Parameterized.Parameters(name = "{0}") - public static List parameters() { - return parameters; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + static { + for ( ObjectStructure singleValuedObjectStructure : new ObjectStructure[] { + ObjectStructure.FLATTENED, + ObjectStructure.NESTED } ) { + ObjectStructure multiValuedObjectStructure = + ObjectStructure.NESTED.equals( singleValuedObjectStructure ) + || TckConfiguration.get().getBackendFeatures() + .reliesOnNestedDocumentsForMultiValuedObjectProjection() + ? ObjectStructure.NESTED + : ObjectStructure.FLATTENED; + DataSet dataSet = new DataSet<>( testValues(), + singleValuedObjectStructure, multiValuedObjectStructure ); + dataSets.add( dataSet ); + parameters.add( + Arguments.of( mainIndex, missingLevel1Index, missingLevel1SingleValuedFieldIndex, missingLevel2Index, + missingLevel2SingleValuedFieldIndex, + dataSet ) ); + } } - public InObjectProjectionIT(DataSet dataSet) { - super( mainIndex, missingLevel1Index, missingLevel1SingleValuedFieldIndex, missingLevel2Index, - missingLevel2SingleValuedFieldIndex, - dataSet ); + public static List params() { + return parameters; } @Override @@ -134,13 +123,13 @@ protected RecursiveComparisonConfiguration.Builder configureRecursiveComparison( @Override protected ProjectionFinalStep singleValuedProjection(SearchProjectionFactory f, - String absoluteFieldPath) { + String absoluteFieldPath, DataSet dataSet) { return f.distance( absoluteFieldPath, dataSet.values.projectionCenterPoint() ); } @Override protected ProjectionFinalStep> multiValuedProjection(SearchProjectionFactory f, - String absoluteFieldPath) { + String absoluteFieldPath, DataSet dataSet) { return f.distance( absoluteFieldPath, dataSet.values.projectionCenterPoint() ).multi(); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionMultiValuedBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionMultiValuedBaseIT.java index 29a9ae4579c..b8d49fbaeda 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionMultiValuedBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionMultiValuedBaseIT.java @@ -31,7 +31,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableGeoPointWithDistanceFromCenterValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.assertion.TestComparators; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; @@ -40,25 +40,24 @@ import org.hibernate.search.util.impl.test.data.Pair; import org.hibernate.search.util.impl.test.data.Triplet; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.assertj.core.api.ListAssert; /** * Tests basic behavior of projections on the distance between a given point and the value of a multi-valued field. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3391") -public class DistanceProjectionMultiValuedBaseIT { +class DistanceProjectionMultiValuedBaseIT { private static final GeoPointFieldTypeDescriptor fieldType = GeoPointFieldTypeDescriptor.INSTANCE; private static final Set> supportedFieldTypes = Collections.singleton( fieldType ); - private static List dataSets; - + private static final List dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); private static final Comparator> APPROX_M_COMPARATOR = TestComparators.lexicographic( TestComparators.APPROX_M_COMPARATOR ); private static final Comparator> APPROX_KM_COMPARATOR = @@ -66,23 +65,23 @@ public class DistanceProjectionMultiValuedBaseIT { private static final Comparator> APPROX_MILES_COMPARATOR = TestComparators.lexicographic( TestComparators.APPROX_MILES_COMPARATOR ); - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { for ( TestedFieldStructure fieldStructure : TestedFieldStructure.all() ) { if ( fieldStructure.isSingleValued() ) { continue; } DataSet dataSet = new DataSet( fieldStructure ); dataSets.add( dataSet ); - parameters.add( new Object[] { fieldStructure, dataSet } ); + parameters.add( Arguments.of( fieldStructure, dataSet ) ); } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( @@ -107,8 +106,8 @@ public static Object[][] parameters() { ) .name( "sortable" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( mainIndex, sortableIndex ).setup(); BulkIndexer mainIndexer = mainIndex.bulkIndexer(); @@ -119,19 +118,12 @@ public static void setup() { mainIndexer.join( sortableIndexer ); } - private final TestedFieldStructure fieldStructure; - private final DataSet dataSet; - - public DistanceProjectionMultiValuedBaseIT(TestedFieldStructure fieldStructure, DataSet dataSet) { - this.fieldStructure = fieldStructure; - this.dataSet = dataSet; - } - - @Test - public void simple() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simple(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); assertThatQuery( scope.query() // Do NOT add any additional projection here: this serves as a non-regression test for HSEARCH-3618 @@ -153,11 +145,12 @@ public void simple() { * Test that mentioning the same projection twice works as expected. */ @SuppressWarnings("unchecked") - @Test - public void duplicated() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void duplicated(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); ListAssert, List>> hitsAssert = assertThatQuery( scope.query() .select( f -> f.composite() @@ -187,9 +180,10 @@ public void duplicated() { ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3618") - public void sortable_withoutSort() { + void sortable_withoutSort(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = sortableIndex.createScope(); String fieldPath = sortableIndex.binding().getFieldPath( fieldStructure, fieldType ); @@ -213,9 +207,10 @@ public void sortable_withoutSort() { * This is relevant because projections on the distance can * be optimized when also sorting by distance to the same point. */ - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3618") - public void sortable_withSort() { + void sortable_withSort(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = sortableIndex.createScope(); String fieldPath = sortableIndex.binding().getFieldPath( fieldStructure, fieldType ); @@ -236,12 +231,13 @@ public void sortable_withSort() { ); } - @Test - public void unit_km() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void unit_km(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); assertThatQuery( scope.query() - .select( f -> f.distance( getFieldPath(), CENTER_POINT_1 ).multi() + .select( f -> f.distance( getFieldPath( fieldStructure ), CENTER_POINT_1 ).multi() .unit( DistanceUnit.KILOMETERS ) ) .where( f -> f.matchAll() ) .routing( dataSet.routingKey ) @@ -256,12 +252,13 @@ public void unit_km() { ); } - @Test - public void unit_miles() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void unit_miles(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); assertThatQuery( scope.query() - .select( f -> f.distance( getFieldPath(), CENTER_POINT_1 ).multi() + .select( f -> f.distance( getFieldPath( fieldStructure ), CENTER_POINT_1 ).multi() .unit( DistanceUnit.MILES ) ) .where( f -> f.matchAll() ) .routing( dataSet.routingKey ) @@ -276,15 +273,17 @@ public void unit_miles() { ); } - @Test - public void several() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void several(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); ListAssert, List, List>> hitsAssert = assertThatQuery( scope.query() .select( f -> f.composite() - .from( f.distance( getFieldPath(), CENTER_POINT_1 ).multi(), - f.distance( getFieldPath(), CENTER_POINT_2 ).multi(), - f.distance( getFieldPath(), CENTER_POINT_1 ).multi().unit( DistanceUnit.KILOMETERS ) ) + .from( f.distance( getFieldPath( fieldStructure ), CENTER_POINT_1 ).multi(), + f.distance( getFieldPath( fieldStructure ), CENTER_POINT_2 ).multi(), + f.distance( getFieldPath( fieldStructure ), CENTER_POINT_1 ).multi() + .unit( DistanceUnit.KILOMETERS ) ) .as( Triplet::new ) ) .where( f -> f.matchAll() ) .routing( dataSet.routingKey ) @@ -317,7 +316,7 @@ public void several() { ); } - private String getFieldPath() { + private String getFieldPath(TestedFieldStructure fieldStructure) { return mainIndex.binding().getFieldPath( fieldStructure, fieldType ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionSingleValuedBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionSingleValuedBaseIT.java index d02ae2d2031..b985f1871b7 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionSingleValuedBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionSingleValuedBaseIT.java @@ -14,7 +14,7 @@ import static org.hibernate.search.util.impl.integrationtest.common.assertion.TestComparators.APPROX_MILES_COMPARATOR; import static org.hibernate.search.util.impl.integrationtest.common.assertion.TestComparators.APPROX_M_COMPARATOR; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.Collections; @@ -33,7 +33,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableGeoPointWithDistanceFromCenterValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.assertion.TestComparators; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; @@ -42,41 +42,42 @@ import org.hibernate.search.util.impl.test.data.Pair; import org.hibernate.search.util.impl.test.data.Triplet; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.assertj.core.api.ListAssert; /** * Tests basic behavior of projections on the distance between a given point and the value of a single-valued field. */ -@RunWith(Parameterized.class) -public class DistanceProjectionSingleValuedBaseIT { +class DistanceProjectionSingleValuedBaseIT { private static final GeoPointFieldTypeDescriptor fieldType = GeoPointFieldTypeDescriptor.INSTANCE; private static final Set> supportedFieldTypes = Collections.singleton( fieldType ); - private static List dataSets; + private static final List dataSets = new ArrayList<>(); - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + + static { for ( TestedFieldStructure fieldStructure : TestedFieldStructure.all() ) { if ( fieldStructure.isMultiValued() ) { continue; } DataSet dataSet = new DataSet( fieldStructure ); dataSets.add( dataSet ); - parameters.add( new Object[] { fieldStructure, dataSet } ); + parameters.add( Arguments.of( fieldStructure, dataSet ) ); } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( @@ -101,8 +102,8 @@ public static Object[][] parameters() { ) .name( "sortable" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( mainIndex, sortableIndex ).setup(); BulkIndexer mainIndexer = mainIndex.bulkIndexer(); @@ -113,19 +114,12 @@ public static void setup() { mainIndexer.join( sortableIndexer ); } - private final TestedFieldStructure fieldStructure; - private final DataSet dataSet; - - public DistanceProjectionSingleValuedBaseIT(TestedFieldStructure fieldStructure, DataSet dataSet) { - this.fieldStructure = fieldStructure; - this.dataSet = dataSet; - } - - @Test - public void simple() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simple(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); assertThatQuery( scope.query() // Do NOT add any additional projection here: this serves as a non-regression test for HSEARCH-3618 @@ -146,12 +140,13 @@ public void simple() { /** * Test requesting a multi-valued projection on a single-valued field. */ - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3391") - public void multi() { + void multi(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); assertThatQuery( scope.query() .select( f -> f.distance( fieldPath, CENTER_POINT_1 ).multi() ) @@ -174,11 +169,12 @@ public void multi() { /** * Test that mentioning the same projection twice works as expected. */ - @Test - public void duplicated() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void duplicated(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); ListAssert> hitsAssert = assertThatQuery( scope.query() .select( f -> f.composite() @@ -208,9 +204,10 @@ public void duplicated() { ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3618") - public void sortable_withoutSort() { + void sortable_withoutSort(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = sortableIndex.createScope(); String fieldPath = sortableIndex.binding().getFieldPath( fieldStructure, fieldType ); @@ -234,9 +231,10 @@ public void sortable_withoutSort() { * This is relevant because projections on the distance can * be optimized when also sorting by distance to the same point. */ - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3618") - public void sortable_withSort() { + void sortable_withSort(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = sortableIndex.createScope(); String fieldPath = sortableIndex.binding().getFieldPath( fieldStructure, fieldType ); @@ -257,12 +255,13 @@ public void sortable_withSort() { ); } - @Test - public void unit_km() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void unit_km(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); assertThatQuery( scope.query() - .select( f -> f.distance( getFieldPath(), CENTER_POINT_1 ) + .select( f -> f.distance( getFieldPath( fieldStructure ), CENTER_POINT_1 ) .unit( DistanceUnit.KILOMETERS ) ) .where( f -> f.matchAll() ) .routing( dataSet.routingKey ) @@ -277,12 +276,13 @@ public void unit_km() { ); } - @Test - public void unit_miles() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void unit_miles(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); assertThatQuery( scope.query() - .select( f -> f.distance( getFieldPath(), CENTER_POINT_1 ) + .select( f -> f.distance( getFieldPath( fieldStructure ), CENTER_POINT_1 ) .unit( DistanceUnit.MILES ) ) .where( f -> f.matchAll() ) .routing( dataSet.routingKey ) @@ -297,15 +297,16 @@ public void unit_miles() { ); } - @Test - public void several() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void several(TestedFieldStructure fieldStructure, DataSet dataSet) { StubMappingScope scope = mainIndex.createScope(); ListAssert> hitsAssert = assertThatQuery( scope.query() .select( f -> f.composite() - .from( f.distance( getFieldPath(), CENTER_POINT_1 ), - f.distance( getFieldPath(), CENTER_POINT_2 ), - f.distance( getFieldPath(), CENTER_POINT_1 ).unit( DistanceUnit.KILOMETERS ) ) + .from( f.distance( getFieldPath( fieldStructure ), CENTER_POINT_1 ), + f.distance( getFieldPath( fieldStructure ), CENTER_POINT_2 ), + f.distance( getFieldPath( fieldStructure ), CENTER_POINT_1 ).unit( DistanceUnit.KILOMETERS ) ) .as( Triplet::new ) ) .where( f -> f.matchAll() ) .routing( dataSet.routingKey ) @@ -338,13 +339,16 @@ public void several() { ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void factoryWithRoot() { + void factoryWithRoot(TestedFieldStructure fieldStructure, DataSet dataSet) { AbstractObjectBinding parentObjectBinding = mainIndex.binding().getParentObject( fieldStructure ); - assumeTrue( "This test is only relevant when the field is located on an object field", - parentObjectBinding.absolutePath != null ); + assumeTrue( + parentObjectBinding.absolutePath != null, + "This test is only relevant when the field is located on an object field" + ); assertThatQuery( mainIndex.query() .select( f -> f.withRoot( parentObjectBinding.absolutePath ) @@ -362,7 +366,7 @@ public void factoryWithRoot() { ); } - private String getFieldPath() { + private String getFieldPath(TestedFieldStructure fieldStructure) { return mainIndex.binding().getFieldPath( fieldStructure, fieldType ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeCheckingAndConversionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeCheckingAndConversionIT.java index 189d00e3be0..c37fadc23ff 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeCheckingAndConversionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeCheckingAndConversionIT.java @@ -9,7 +9,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.IndexableGeoPointWithDistanceFromCenterValues.CENTER_POINT_1; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; -import static org.junit.Assume.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import org.hibernate.search.engine.backend.document.DocumentElement; import org.hibernate.search.engine.backend.document.IndexObjectFieldReference; @@ -30,7 +30,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.assertion.TestComparators; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; @@ -38,15 +38,15 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests behavior related to type checking and type conversion of * projections on the distance between a field value and a given point. */ -public class DistanceProjectionTypeCheckingAndConversionIT { +class DistanceProjectionTypeCheckingAndConversionIT { private static final GeoPointFieldTypeDescriptor fieldType = GeoPointFieldTypeDescriptor.INSTANCE; @@ -59,8 +59,8 @@ public class DistanceProjectionTypeCheckingAndConversionIT { private static final String RAW_FIELD_COMPATIBLE_INDEX_DOCUMENT_1 = "raw_field_compatible_1"; private static final String MISSING_FIELD_INDEX_DOCUMENT_1 = "missing_field_1"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -73,8 +73,8 @@ public class DistanceProjectionTypeCheckingAndConversionIT { private static final SimpleMappedIndex incompatibleIndex = SimpleMappedIndex.of( IncompatibleIndexBinding::new ).name( "incompatible" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( mainIndex, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex ) .setup(); @@ -83,7 +83,7 @@ public static void setup() { } @Test - public void nonProjectable() { + void nonProjectable() { StubMappingScope scope = mainIndex.createScope(); String fieldPath = getNonProjectableFieldPath(); @@ -98,10 +98,10 @@ public void nonProjectable() { } @Test - public void projectableDefault() { + void projectableDefault() { assumeFalse( - "Skipping this test as the backend makes fields projectable by default.", - TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault() + TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault(), + "Skipping this test as the backend makes fields projectable by default." ); StubMappingScope scope = mainIndex.createScope(); @@ -118,7 +118,7 @@ public void projectableDefault() { @Test @TestForIssue(jiraKey = "HSEARCH-3391") - public void multiValuedField_singleValuedProjection() { + void multiValuedField_singleValuedProjection() { StubMappingScope scope = mainIndex.createScope(); String fieldPath = mainIndex.binding().fieldWithMultipleValuesModel.relativeFieldName; @@ -135,7 +135,7 @@ public void multiValuedField_singleValuedProjection() { @Test @TestForIssue(jiraKey = "HSEARCH-3391") - public void singleValuedFieldInMultiValuedObjectField_flattened_singleValuedProjection() { + void singleValuedFieldInMultiValuedObjectField_flattened_singleValuedProjection() { String fieldPath = mainIndex.binding().flattenedObjectWithMultipleValues.relativeFieldName + "." + mainIndex.binding().flattenedObjectWithMultipleValues.fieldModel.relativeFieldName; @@ -153,7 +153,7 @@ public void singleValuedFieldInMultiValuedObjectField_flattened_singleValuedProj @Test @TestForIssue(jiraKey = "HSEARCH-3391") - public void singleValuedFieldInMultiValuedObjectField_nested_singleValuedProjection() { + void singleValuedFieldInMultiValuedObjectField_nested_singleValuedProjection() { String fieldPath = mainIndex.binding().nestedObjectWithMultipleValues.relativeFieldName + "." + mainIndex.binding().nestedObjectWithMultipleValues.fieldModel.relativeFieldName; @@ -170,7 +170,7 @@ public void singleValuedFieldInMultiValuedObjectField_nested_singleValuedProject } @Test - public void withProjectionConverters() { + void withProjectionConverters() { StubMappingScope scope = mainIndex.createScope(); String fieldPath = getFieldWithConverterPath(); @@ -190,7 +190,7 @@ public void withProjectionConverters() { } @Test - public void multiIndex_withCompatibleIndex() { + void multiIndex_withCompatibleIndex() { StubMappingScope scope = mainIndex.createScope( compatibleIndex ); assertThatQuery( scope.query() @@ -209,7 +209,7 @@ public void multiIndex_withCompatibleIndex() { } @Test - public void multiIndex_withRawFieldCompatibleIndex() { + void multiIndex_withRawFieldCompatibleIndex() { StubMappingScope scope = mainIndex.createScope( rawFieldCompatibleIndex ); assertThatQuery( scope.query() @@ -229,7 +229,7 @@ public void multiIndex_withRawFieldCompatibleIndex() { @Test @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex() { + void multiIndex_withMissingFieldIndex() { StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); assertThatQuery( scope.query() @@ -248,7 +248,7 @@ public void multiIndex_withMissingFieldIndex() { } @Test - public void multiIndex_withIncompatibleIndex() { + void multiIndex_withIncompatibleIndex() { StubMappingScope scope = mainIndex.createScope( incompatibleIndex ); String fieldPath = getFieldPath(); @@ -262,7 +262,7 @@ public void multiIndex_withIncompatibleIndex() { } @Test - public void multiIndex_withIncompatibleIndex_inNestedObject() { + void multiIndex_withIncompatibleIndex_inNestedObject() { StubMappingScope scope = incompatibleIndex.createScope( mainIndex ); String fieldPath = mainIndex.binding().nestedObject.relativeFieldName + "." diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeIndependentIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeIndependentIT.java index 12e4b5e99a4..1e82ec5bb55 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeIndependentIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionTypeIndependentIT.java @@ -16,14 +16,14 @@ import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to behavior independent from the field type @@ -32,22 +32,22 @@ * Behavior that is specific to the field type is tested elsewhere, * e.g. {@link DistanceProjectionSingleValuedBaseIT} and {@link DistanceProjectionTypeCheckingAndConversionIT}. */ -public class DistanceProjectionTypeIndependentIT { +class DistanceProjectionTypeIndependentIT { private static final GeoPoint SOME_POINT = GeoPoint.of( 45.749828, 4.854172 ); - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void unknownField() { + void unknownField() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.projection() @@ -62,7 +62,7 @@ public void unknownField() { } @Test - public void nullCenter() { + void nullCenter() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.projection() @@ -77,7 +77,7 @@ public void nullCenter() { } @Test - public void nullUnit() { + void nullUnit() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.projection() @@ -92,7 +92,7 @@ public void nullUnit() { } @Test - public void objectField_nested() { + void objectField_nested() { String fieldPath = index.binding().nestedObject.relativeFieldName; StubMappingScope scope = index.createScope(); @@ -103,7 +103,7 @@ public void objectField_nested() { } @Test - public void objectField_flattened() { + void objectField_flattened() { String fieldPath = index.binding().flattenedObject.relativeFieldName; StubMappingScope scope = index.createScope(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionUnsupportedTypesIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionUnsupportedTypesIT.java index 8e7778af860..f03804ffc5c 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionUnsupportedTypesIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/DistanceProjectionUnsupportedTypesIT.java @@ -16,58 +16,51 @@ import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests basic behavior of distance projection common to all unsupported types, * i.e. error messages. */ -@RunWith(Parameterized.class) -public class DistanceProjectionUnsupportedTypesIT { +class DistanceProjectionUnsupportedTypesIT { private static Stream> unsupportedTypeDescriptors() { return FieldTypeDescriptor.getAll().stream() .filter( typeDescriptor -> !GeoPoint.class.isAssignableFrom( typeDescriptor.getJavaType() ) ); } - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - List parameters = new ArrayList<>(); + public static List params() { + List parameters = new ArrayList<>(); unsupportedTypeDescriptors().forEach( fieldTypeDescriptor -> { - parameters.add( new Object[] { fieldTypeDescriptor } ); + parameters.add( Arguments.of( fieldTypeDescriptor ) ); } ); - return parameters.toArray( new Object[0][] ); + return parameters; } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldTypeDescriptor; - - public DistanceProjectionUnsupportedTypesIT(FieldTypeDescriptor fieldTypeDescriptor) { - this.fieldTypeDescriptor = fieldTypeDescriptor; - } - - @Test - public void notSupported() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void notSupported(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = index.createScope(); - String absoluteFieldPath = getFieldPath(); + String absoluteFieldPath = getFieldPath( fieldTypeDescriptor ); assertThatThrownBy( () -> scope.projection().distance( absoluteFieldPath, GeoPoint.of( 42.0, 45.0 ) ) @@ -79,7 +72,7 @@ public void notSupported() { ); } - private String getFieldPath() { + private String getFieldPath(FieldTypeDescriptor fieldTypeDescriptor) { return index.binding().fieldModels.get( fieldTypeDescriptor ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityProjectionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityProjectionIT.java index fc9a3c89866..329884be1cb 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityProjectionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityProjectionIT.java @@ -29,24 +29,24 @@ import org.hibernate.search.engine.search.query.dsl.SearchQuerySelectStep; import org.hibernate.search.engine.search.query.dsl.SearchQueryWhereStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.stub.StubEntity; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.GenericStubMappingScope; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mockito; @SuppressWarnings("unchecked") // Mocking parameterized types -public class EntityProjectionIT extends AbstractEntityProjectionIT { +class EntityProjectionIT extends AbstractEntityProjectionIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ) .name( "main" ); @@ -63,8 +63,8 @@ public EntityProjectionIT() { super( mainIndex, multiIndex1, multiIndex2, multiIndex3, multiIndex4 ); } - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndexes( mainIndex, multiIndex1, multiIndex2, multiIndex3, multiIndex4 ).setup(); final BulkIndexer mainIndexer = mainIndex.bulkIndexer(); @@ -89,7 +89,7 @@ public static void setup() { // it should not try to retrieve fields from the object, but from the root. @Test @TestForIssue(jiraKey = "HSEARCH-4579") - public void projectionRegistryFallback_noLoadingAvailable_withProjectionRegistryEntry_inObjectProjection_ignoresObjectContext() { + void projectionRegistryFallback_noLoadingAvailable_withProjectionRegistryEntry_inObjectProjection_ignoresObjectContext() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); @@ -157,7 +157,7 @@ public void projectionRegistryFallback_noLoadingAvailable_withProjectionRegistry @Test @TestForIssue(jiraKey = "HSEARCH-4574") - public void expectedType_exact() { + void expectedType_exact() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); StubEntity doc1LoadedEntity = new StubEntity( doc1Reference ); @@ -191,7 +191,7 @@ public void expectedType_exact() { @Test @TestForIssue(jiraKey = "HSEARCH-4574") - public void expectedType_superType() { + void expectedType_superType() { DocumentReference doc1Reference = reference( mainIndex.typeName(), DOCUMENT_1_ID ); DocumentReference doc2Reference = reference( mainIndex.typeName(), DOCUMENT_2_ID ); StubEntity doc1LoadedEntity = new StubEntity( doc1Reference ); @@ -225,7 +225,7 @@ public void expectedType_superType() { @Test @TestForIssue(jiraKey = "HSEARCH-4574") - public void expectedType_invalid() { + void expectedType_invalid() { SearchLoadingContext loadingContextMock = mock( SearchLoadingContext.class ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityReferenceProjectionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityReferenceProjectionIT.java index 60d650e8378..d64997829d1 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityReferenceProjectionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/EntityReferenceProjectionIT.java @@ -8,17 +8,17 @@ import org.hibernate.search.engine.search.query.dsl.SearchQuerySelectStep; import org.hibernate.search.engine.search.query.dsl.SearchQueryWhereStep; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; -public class EntityReferenceProjectionIT extends AbstractEntityReferenceProjectionIT { +class EntityReferenceProjectionIT extends AbstractEntityReferenceProjectionIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final StubMappedIndex mainIndex = StubMappedIndex.withoutFields(); @@ -26,8 +26,8 @@ public EntityReferenceProjectionIT() { super( mainIndex ); } - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( mainIndex ).setup(); BulkIndexer indexer = mainIndex.bulkIndexer(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionAndSortNestedIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionAndSortNestedIT.java index 0a795655438..c67ec0ae82d 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionAndSortNestedIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionAndSortNestedIT.java @@ -20,30 +20,30 @@ import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4584") -public class FieldProjectionAndSortNestedIT { +class FieldProjectionAndSortNestedIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void before() { + @BeforeEach + void before() { setupHelper.start().withIndex( index ).setup(); } @Test - public void test() { + void test() { index.index( "1", doc -> { doc.addValue( index.binding().year, 1845 ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionBaseIT.java index 2df3541341a..5b17c225bda 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionBaseIT.java @@ -16,32 +16,31 @@ import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; -@RunWith(NestedRunner.class) -public class FieldProjectionBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class FieldProjectionBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static FieldProjectionTestValues testValues(FieldTypeDescriptor fieldType) { return new FieldProjectionTestValues<>( fieldType ); } - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( InObjectProjectionIT.mainIndex, InObjectProjectionIT.missingLevel1Index, InObjectProjectionIT.missingLevel1SingleValuedFieldIndex, @@ -67,18 +66,28 @@ public static void setup() { compositeForEachMissingLevel2SingleValuedFieldIndexer ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - @RunWith(Parameterized.class) - public static class InObjectProjectionIT + class InObjectProjectionIT extends AbstractProjectionInObjectProjectionIT> { private static final List> supportedFieldTypes = FieldTypeDescriptor.getAll(); + private static final SimpleMappedIndex mainIndex = + SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) + .name( "main" ); + private static final SimpleMappedIndex missingLevel1Index = + SimpleMappedIndex.of( MissingLevel1IndexBinding::new ) + .name( "missingLevel1" ); + private static final SimpleMappedIndex missingLevel1SingleValuedFieldIndex = + SimpleMappedIndex.of( root -> new MissingLevel1SingleValuedFieldIndexBinding( root, supportedFieldTypes ) ) + .name( "missingLevel1Field1" ); + private static final SimpleMappedIndex missingLevel2Index = + SimpleMappedIndex.of( root -> new MissingLevel2IndexBinding( root, supportedFieldTypes ) ) + .name( "missingLevel2" ); + private static final SimpleMappedIndex missingLevel2SingleValuedFieldIndex = + SimpleMappedIndex.of( root -> new MissingLevel2SingleValuedFieldIndexBinding( root, supportedFieldTypes ) ) + .name( "missingLevel2Field1" ); + private static final List> dataSets = new ArrayList<>(); - private static final List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { for ( ObjectStructure singleValuedObjectStructure : new ObjectStructure[] { @@ -93,38 +102,18 @@ public static class InObjectProjectionIT DataSet dataSet = new DataSet<>( testValues( fieldType ), singleValuedObjectStructure, multiValuedObjectStructure ); dataSets.add( dataSet ); - parameters.add( new Object[] { dataSet } ); + parameters.add( Arguments.of( mainIndex, missingLevel1Index, missingLevel1SingleValuedFieldIndex, + missingLevel2Index, + missingLevel2SingleValuedFieldIndex, + dataSet ) ); } } } - private static final SimpleMappedIndex mainIndex = - SimpleMappedIndex.of( root -> new IndexBinding( root, supportedFieldTypes ) ) - .name( "main" ); - private static final SimpleMappedIndex missingLevel1Index = - SimpleMappedIndex.of( MissingLevel1IndexBinding::new ) - .name( "missingLevel1" ); - private static final SimpleMappedIndex missingLevel1SingleValuedFieldIndex = - SimpleMappedIndex.of( root -> new MissingLevel1SingleValuedFieldIndexBinding( root, supportedFieldTypes ) ) - .name( "missingLevel1Field1" ); - private static final SimpleMappedIndex missingLevel2Index = - SimpleMappedIndex.of( root -> new MissingLevel2IndexBinding( root, supportedFieldTypes ) ) - .name( "missingLevel2" ); - private static final SimpleMappedIndex missingLevel2SingleValuedFieldIndex = - SimpleMappedIndex.of( root -> new MissingLevel2SingleValuedFieldIndexBinding( root, supportedFieldTypes ) ) - .name( "missingLevel2Field1" ); - - @Parameterized.Parameters(name = "{0}") - public static List parameters() { + public static List params() { return parameters; } - public InObjectProjectionIT(DataSet> dataSet) { - super( mainIndex, missingLevel1Index, missingLevel1SingleValuedFieldIndex, missingLevel2Index, - missingLevel2SingleValuedFieldIndex, - dataSet ); - } - @Override protected RecursiveComparisonConfiguration.Builder configureRecursiveComparison( RecursiveComparisonConfiguration.Builder builder) { @@ -133,13 +122,13 @@ protected RecursiveComparisonConfiguration.Builder configureRecursiveComparison( @Override protected ProjectionFinalStep singleValuedProjection(SearchProjectionFactory f, - String absoluteFieldPath) { + String absoluteFieldPath, DataSet> dataSet) { return f.field( absoluteFieldPath, dataSet.fieldType.getJavaType() ); } @Override protected ProjectionFinalStep> multiValuedProjection(SearchProjectionFactory f, - String absoluteFieldPath) { + String absoluteFieldPath, DataSet> dataSet) { return f.field( absoluteFieldPath, dataSet.fieldType.getJavaType() ).multi(); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionMultiValuedBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionMultiValuedBaseIT.java index 0a22d6f5302..7d72554cdca 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionMultiValuedBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionMultiValuedBaseIT.java @@ -22,34 +22,32 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests basic behavior of projections on a multi-valued field, common to all supported types. *

* See {@link FieldProjectionSingleValuedBaseIT} for single-valued fields. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3391") -public class FieldProjectionMultiValuedBaseIT { +class FieldProjectionMultiValuedBaseIT { private static final List> supportedFieldTypes = FieldTypeDescriptor.getAll(); - private static List> dataSets; + private static final List> dataSets = new ArrayList<>(); - @Parameterized.Parameters(name = "{0} - {1}") - public static Object[][] parameters() { - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); + + static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { for ( TestedFieldStructure fieldStructure : TestedFieldStructure.all() ) { if ( fieldStructure.isSingleValued() ) { @@ -57,14 +55,17 @@ public static Object[][] parameters() { } DataSet dataSet = new DataSet<>( fieldStructure, fieldType ); dataSets.add( dataSet ); - parameters.add( new Object[] { fieldStructure, fieldType, dataSet } ); + parameters.add( Arguments.of( fieldStructure, fieldType, dataSet ) ); } } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final Function bindingFactory = root -> SingleFieldIndexBinding.create( @@ -77,8 +78,8 @@ public static Object[][] parameters() { private static final SimpleMappedIndex index = SimpleMappedIndex.of( bindingFactory ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -88,22 +89,12 @@ public static void setup() { indexer.join(); } - private final TestedFieldStructure fieldStructure; - private final FieldTypeDescriptor fieldType; - private final DataSet dataSet; - - public FieldProjectionMultiValuedBaseIT(TestedFieldStructure fieldStructure, - FieldTypeDescriptor fieldType, DataSet dataSet) { - this.fieldStructure = fieldStructure; - this.fieldType = fieldType; - this.dataSet = dataSet; - } - - @Test - public void simple() { + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void simple(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType, DataSet dataSet) { StubMappingScope scope = index.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, fieldType.getJavaType() ).multi() ) @@ -118,11 +109,12 @@ public void simple() { ); } - @Test - public void noClass() { + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void noClass(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType, DataSet dataSet) { StubMappingScope scope = index.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath ).multi() ) @@ -140,11 +132,12 @@ public void noClass() { /** * Test that mentioning the same projection twice works as expected. */ - @Test - public void duplicated() { + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void duplicated(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType, DataSet dataSet) { StubMappingScope scope = index.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); assertThatQuery( scope.query() .select( f -> f.composite( @@ -163,7 +156,7 @@ public void duplicated() { ); } - private String getFieldPath() { + private String getFieldPath(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType) { return index.binding().getFieldPath( fieldStructure, fieldType ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionSingleValuedBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionSingleValuedBaseIT.java index 6dd118eeed4..092781357c8 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionSingleValuedBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionSingleValuedBaseIT.java @@ -9,7 +9,7 @@ import static org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.SingleFieldIndexBinding.NO_ADDITIONAL_CONFIGURATION; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.Arrays; @@ -24,33 +24,30 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests basic behavior of projections on a single-valued field, common to all supported types. *

* See {@link FieldProjectionMultiValuedBaseIT} for multi-valued fields. */ -@RunWith(Parameterized.class) -public class FieldProjectionSingleValuedBaseIT { +class FieldProjectionSingleValuedBaseIT { private static final List> supportedFieldTypes = FieldTypeDescriptor.getAll(); - private static List> dataSets; + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0} - {1}") - public static Object[][] parameters() { - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { for ( TestedFieldStructure fieldStructure : TestedFieldStructure.all() ) { if ( fieldStructure.isMultiValued() ) { @@ -58,14 +55,17 @@ public static Object[][] parameters() { } DataSet dataSet = new DataSet<>( fieldStructure, fieldType ); dataSets.add( dataSet ); - parameters.add( new Object[] { fieldStructure, fieldType, dataSet } ); + parameters.add( Arguments.of( fieldStructure, fieldType, dataSet ) ); } } - return parameters.toArray( new Object[0][] ); } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + public static List params() { + return parameters; + } + + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final Function bindingFactory = root -> SingleFieldIndexBinding.createWithSingleValuedNestedFields( @@ -78,8 +78,8 @@ public static Object[][] parameters() { private static final SimpleMappedIndex index = SimpleMappedIndex.of( bindingFactory ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -89,22 +89,13 @@ public static void setup() { indexer.join(); } - private final TestedFieldStructure fieldStructure; - private final FieldTypeDescriptor fieldType; - private final DataSet dataSet; - - public FieldProjectionSingleValuedBaseIT(TestedFieldStructure fieldStructure, + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void simple(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType, DataSet dataSet) { - this.fieldStructure = fieldStructure; - this.fieldType = fieldType; - this.dataSet = dataSet; - } - - @Test - public void simple() { StubMappingScope scope = index.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, fieldType.getJavaType() ) ) @@ -119,11 +110,13 @@ public void simple() { ); } - @Test - public void noClass() { + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void noClass(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, DataSet dataSet) { StubMappingScope scope = index.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath ) ) @@ -141,12 +134,14 @@ public void noClass() { /** * Test requesting a multi-valued projection on a single-valued field. */ - @Test + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3391") - public void multi() { + void multi(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, DataSet dataSet) { StubMappingScope scope = index.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, fieldType.getJavaType() ).multi() ) @@ -167,11 +162,13 @@ public void multi() { /** * Test that mentioning the same projection twice works as expected. */ - @Test - public void duplicated() { + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") + void duplicated(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, DataSet dataSet) { StubMappingScope scope = index.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); assertThatQuery( scope.query() .select( f -> f.composite( @@ -190,13 +187,17 @@ public void duplicated() { ); } - @Test + @ParameterizedTest(name = "{0} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void factoryWithRoot() { + void factoryWithRoot(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, DataSet dataSet) { AbstractObjectBinding parentObjectBinding = index.binding().getParentObject( fieldStructure ); - assumeTrue( "This test is only relevant when the field is located on an object field", - parentObjectBinding.absolutePath != null ); + assumeTrue( + parentObjectBinding.absolutePath != null, + "This test is only relevant when the field is located on an object field" + ); assertThatQuery( index.query() .select( f -> f.withRoot( parentObjectBinding.absolutePath ) @@ -213,7 +214,7 @@ public void factoryWithRoot() { ); } - private String getFieldPath() { + private String getFieldPath(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType) { return index.binding().getFieldPath( fieldStructure, fieldType ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeCheckingAndConversionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeCheckingAndConversionIT.java index d71ed1cf9f9..bacd1684521 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeCheckingAndConversionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeCheckingAndConversionIT.java @@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; -import static org.junit.Assume.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import java.util.ArrayList; import java.util.List; @@ -31,35 +31,33 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests behavior related to type checking and type conversion of * projections on field value. */ -@RunWith(Parameterized.class) -public class FieldProjectionTypeCheckingAndConversionIT { +class FieldProjectionTypeCheckingAndConversionIT { private static final List> supportedFieldTypes = FieldTypeDescriptor.getAll(); - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - List parameters = new ArrayList<>(); + public static List params() { + List parameters = new ArrayList<>(); for ( FieldTypeDescriptor fieldType : supportedFieldTypes ) { - parameters.add( new Object[] { fieldType } ); + parameters.add( Arguments.of( fieldType ) ); } - return parameters.toArray( new Object[0][] ); + return parameters; } private static final String DOCUMENT_1 = "1"; @@ -71,8 +69,8 @@ public static Object[][] parameters() { private static final String RAW_FIELD_COMPATIBLE_INDEX_DOCUMENT_1 = "raw_field_compatible_1"; private static final String MISSING_FIELD_INDEX_DOCUMENT_1 = "missing_field_1"; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -85,8 +83,8 @@ public static Object[][] parameters() { private static final SimpleMappedIndex incompatibleIndex = SimpleMappedIndex.of( IncompatibleIndexBinding::new ).name( "incompatible" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( mainIndex, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex ) .setup(); @@ -94,14 +92,9 @@ public static void setup() { initData(); } - private final FieldTypeDescriptor fieldType; - - public FieldProjectionTypeCheckingAndConversionIT(FieldTypeDescriptor fieldType) { - this.fieldType = fieldType; - } - - @Test - public void validSuperClass() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void validSuperClass(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); Class closestSuperClass = fieldType.getJavaType().getSuperclass(); @@ -111,22 +104,23 @@ public void validSuperClass() { final Class validSuperClass = closestSuperClass; assertThatQuery( scope.query() - .select( f -> f.field( getFieldPath(), validSuperClass ) ) + .select( f -> f.field( getFieldPath( fieldType ), validSuperClass ) ) .where( f -> f.matchAll() ) .toQuery() ) .hasHitsAnyOrder( - getFieldValue( 1 ), - getFieldValue( 2 ), - getFieldValue( 3 ), + getFieldValue( 1, fieldType ), + getFieldValue( 2, fieldType ), + getFieldValue( 3, fieldType ), null // Empty document ); } - @Test - public void invalidProjectionType_projectionConverterEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidProjectionType_projectionConverterEnabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldType ); Class wrongType = FieldTypeDescriptor.getIncompatible( fieldType ).getJavaType(); @@ -140,11 +134,12 @@ public void invalidProjectionType_projectionConverterEnabled() { ); } - @Test - public void invalidProjectionType_projectionConverterDisabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidProjectionType_projectionConverterDisabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldType ); Class wrongType = FieldTypeDescriptor.getIncompatible( fieldType ).getJavaType(); @@ -158,11 +153,12 @@ public void invalidProjectionType_projectionConverterDisabled() { ); } - @Test - public void nonProjectable() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void nonProjectable(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getNonProjectableFieldPath(); + String fieldPath = getNonProjectableFieldPath( fieldType ); assertThatThrownBy( () -> scope.projection() .field( fieldPath, fieldType.getJavaType() ).toProjection() ) @@ -173,15 +169,16 @@ public void nonProjectable() { ); } - @Test - public void projectableDefault() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectableDefault(FieldTypeDescriptor fieldType) { assumeFalse( - "Skipping this test as the backend makes fields projectable by default.", - TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault() + TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault(), + "Skipping this test as the backend makes fields projectable by default." ); StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getNonProjectableFieldPath(); + String fieldPath = getNonProjectableFieldPath( fieldType ); assertThatThrownBy( () -> scope.projection() .field( fieldPath, fieldType.getJavaType() ).toProjection() ) @@ -192,9 +189,10 @@ public void projectableDefault() { ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3391") - public void multiValuedField_singleValuedProjection() { + void multiValuedField_singleValuedProjection(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); String fieldPath = mainIndex.binding().fieldWithMultipleValuesModels.get( fieldType ).relativeFieldName; @@ -209,9 +207,10 @@ public void multiValuedField_singleValuedProjection() { ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3391") - public void singleValuedFieldInMultiValuedObjectField_flattened_singleValuedProjection() { + void singleValuedFieldInMultiValuedObjectField_flattened_singleValuedProjection(FieldTypeDescriptor fieldType) { String fieldPath = mainIndex.binding().flattenedObjectWithMultipleValues.relativeFieldName + "." + mainIndex.binding().flattenedObjectWithMultipleValues.fieldModels.get( fieldType ).relativeFieldName; @@ -227,9 +226,10 @@ public void singleValuedFieldInMultiValuedObjectField_flattened_singleValuedProj ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3391") - public void singleValuedFieldInMultiValuedObjectField_nested_singleValuedProjection() { + void singleValuedFieldInMultiValuedObjectField_nested_singleValuedProjection(FieldTypeDescriptor fieldType) { String fieldPath = mainIndex.binding().nestedObjectWithMultipleValues.relativeFieldName + "." + mainIndex.binding().nestedObjectWithMultipleValues.fieldModels.get( fieldType ).relativeFieldName; @@ -245,65 +245,69 @@ public void singleValuedFieldInMultiValuedObjectField_nested_singleValuedProject ); } - @Test - public void withProjectionConverters_projectionConverterEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withProjectionConverters_projectionConverterEnabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldWithConverterPath(); + String fieldPath = getFieldWithConverterPath( fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, ValueWrapper.class ) ) .where( f -> f.matchAll() ) .toQuery() ) .hasHitsAnyOrder( - new ValueWrapper<>( getFieldValue( 1 ) ), - new ValueWrapper<>( getFieldValue( 2 ) ), - new ValueWrapper<>( getFieldValue( 3 ) ), + new ValueWrapper<>( getFieldValue( 1, fieldType ) ), + new ValueWrapper<>( getFieldValue( 2, fieldType ) ), + new ValueWrapper<>( getFieldValue( 3, fieldType ) ), new ValueWrapper<>( null ) ); } - @Test - public void withProjectionConverters_projectionConverterDisabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withProjectionConverters_projectionConverterDisabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldWithConverterPath(); + String fieldPath = getFieldWithConverterPath( fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, fieldType.getJavaType(), ValueConvert.NO ) ) .where( f -> f.matchAll() ) .toQuery() ) .hasHitsAnyOrder( - getFieldValue( 1 ), - getFieldValue( 2 ), - getFieldValue( 3 ), + getFieldValue( 1, fieldType ), + getFieldValue( 2, fieldType ), + getFieldValue( 3, fieldType ), null // Empty document ); } - @Test - public void withProjectionConverters_projectionConverterDisabled_withoutType() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withProjectionConverters_projectionConverterDisabled_withoutType(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldWithConverterPath(); + String fieldPath = getFieldWithConverterPath( fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, ValueConvert.NO ) ) .where( f -> f.matchAll() ) .toQuery() ) .hasHitsAnyOrder( - getFieldValue( 1 ), - getFieldValue( 2 ), - getFieldValue( 3 ), + getFieldValue( 1, fieldType ), + getFieldValue( 2, fieldType ), + getFieldValue( 3, fieldType ), null // Empty document ); } - @Test - public void invalidProjectionType_withProjectionConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidProjectionType_withProjectionConverter(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getFieldWithConverterPath(); + String fieldPath = getFieldWithConverterPath( fieldType ); assertThatThrownBy( () -> scope.projection() .field( fieldPath, String.class ) @@ -316,47 +320,50 @@ public void invalidProjectionType_withProjectionConverter() { ); } - @Test - public void multiIndex_withCompatibleIndex_noProjectionConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withCompatibleIndex_noProjectionConverter(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope( compatibleIndex ); assertThatQuery( scope.query() - .select( f -> f.field( getFieldPath(), fieldType.getJavaType() ) ) + .select( f -> f.field( getFieldPath( fieldType ), fieldType.getJavaType() ) ) .where( f -> f.matchAll() ) .toQuery() ) .hasHitsAnyOrder( - getFieldValue( 1 ), - getFieldValue( 2 ), - getFieldValue( 3 ), + getFieldValue( 1, fieldType ), + getFieldValue( 2, fieldType ), + getFieldValue( 3, fieldType ), null, // Empty document - getFieldValue( 1 ) // From the "compatible" index + getFieldValue( 1, fieldType ) // From the "compatible" index ); } - @Test - public void multiIndex_withCompatibleIndex_projectionConverterEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withCompatibleIndex_projectionConverterEnabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope( compatibleIndex ); - String fieldPath = getFieldWithConverterPath(); + String fieldPath = getFieldWithConverterPath( fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, ValueWrapper.class ) ) .where( f -> f.matchAll() ) .toQuery() ) .hasHitsAnyOrder( - new ValueWrapper<>( getFieldValue( 1 ) ), - new ValueWrapper<>( getFieldValue( 2 ) ), - new ValueWrapper<>( getFieldValue( 3 ) ), + new ValueWrapper<>( getFieldValue( 1, fieldType ) ), + new ValueWrapper<>( getFieldValue( 2, fieldType ) ), + new ValueWrapper<>( getFieldValue( 3, fieldType ) ), new ValueWrapper<>( null ), // Empty document - new ValueWrapper<>( getFieldValue( 1 ) ) // From the "compatible" index + new ValueWrapper<>( getFieldValue( 1, fieldType ) ) // From the "compatible" index ); } - @Test - public void multiIndex_withRawFieldCompatibleIndex_projectionConverterEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withRawFieldCompatibleIndex_projectionConverterEnabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope( rawFieldCompatibleIndex ); - String fieldPath = getFieldWithConverterPath(); + String fieldPath = getFieldWithConverterPath( fieldType ); assertThatThrownBy( () -> scope.projection().field( fieldPath ) ) .isInstanceOf( SearchException.class ) @@ -366,70 +373,74 @@ public void multiIndex_withRawFieldCompatibleIndex_projectionConverterEnabled() ); } - @Test - public void multiIndex_withRawFieldCompatibleIndex_projectionConverterDisabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withRawFieldCompatibleIndex_projectionConverterDisabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope( rawFieldCompatibleIndex ); - String fieldPath = getFieldWithConverterPath(); + String fieldPath = getFieldWithConverterPath( fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, fieldType.getJavaType(), ValueConvert.NO ) ) .where( f -> f.matchAll() ) .toQuery() ) .hasHitsAnyOrder( - getFieldValue( 1 ), - getFieldValue( 2 ), - getFieldValue( 3 ), + getFieldValue( 1, fieldType ), + getFieldValue( 2, fieldType ), + getFieldValue( 3, fieldType ), null, // Empty document - getFieldValue( 1 ) // From the "compatible" index + getFieldValue( 1, fieldType ) // From the "compatible" index ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex_projectionConverterEnabled() { + void multiIndex_withMissingFieldIndex_projectionConverterEnabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); - String fieldPath = getFieldWithConverterPath(); + String fieldPath = getFieldWithConverterPath( fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, ValueWrapper.class ) ) .where( f -> f.matchAll() ) .toQuery() ) .hasHitsAnyOrder( - new ValueWrapper( getFieldValue( 1 ) ), - new ValueWrapper( getFieldValue( 2 ) ), - new ValueWrapper( getFieldValue( 3 ) ), + new ValueWrapper( getFieldValue( 1, fieldType ) ), + new ValueWrapper( getFieldValue( 2, fieldType ) ), + new ValueWrapper( getFieldValue( 3, fieldType ) ), new ValueWrapper( null ), // Empty document new ValueWrapper( null ) // From the "missing field" index ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex_projectionConverterDisabled() { + void multiIndex_withMissingFieldIndex_projectionConverterDisabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); - String fieldPath = getFieldWithConverterPath(); + String fieldPath = getFieldWithConverterPath( fieldType ); assertThatQuery( scope.query() .select( f -> f.field( fieldPath, fieldType.getJavaType(), ValueConvert.NO ) ) .where( f -> f.matchAll() ) .toQuery() ) .hasHitsAnyOrder( - getFieldValue( 1 ), - getFieldValue( 2 ), - getFieldValue( 3 ), + getFieldValue( 1, fieldType ), + getFieldValue( 2, fieldType ), + getFieldValue( 3, fieldType ), null, // Empty document null // From the "missing field" index ); } - @Test - public void multiIndex_withIncompatibleIndex_projectionConverterEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex_projectionConverterEnabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope( incompatibleIndex ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldType ); assertThatThrownBy( () -> scope.projection().field( fieldPath ) ) .isInstanceOf( SearchException.class ) @@ -439,11 +450,12 @@ public void multiIndex_withIncompatibleIndex_projectionConverterEnabled() { ); } - @Test - public void multiIndex_withIncompatibleIndex_projectionConverterDisabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex_projectionConverterDisabled(FieldTypeDescriptor fieldType) { StubMappingScope scope = mainIndex.createScope( incompatibleIndex ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldType ); assertThatThrownBy( () -> scope.projection().field( fieldPath, ValueConvert.NO ) ) .isInstanceOf( SearchException.class ) @@ -453,8 +465,9 @@ public void multiIndex_withIncompatibleIndex_projectionConverterDisabled() { ); } - @Test - public void multiIndex_withIncompatibleIndex_inNestedObject() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex_inNestedObject(FieldTypeDescriptor fieldType) { StubMappingScope scope = incompatibleIndex.createScope( mainIndex ); String fieldPath = mainIndex.binding().nestedObject.relativeFieldName + "." @@ -468,23 +481,23 @@ public void multiIndex_withIncompatibleIndex_inNestedObject() { ); } - private String getFieldPath() { + private String getFieldPath(FieldTypeDescriptor fieldType) { return mainIndex.binding().fieldModels.get( fieldType ).relativeFieldName; } - private String getFieldWithConverterPath() { + private String getFieldWithConverterPath(FieldTypeDescriptor fieldType) { return mainIndex.binding().fieldWithConverterModels.get( fieldType ).relativeFieldName; } - private String getNonProjectableFieldPath() { + private String getNonProjectableFieldPath(FieldTypeDescriptor fieldType) { return mainIndex.binding().fieldWithProjectionDisabledModels.get( fieldType ).relativeFieldName; } - private String getProjectableDefaultFieldPath() { + private String getProjectableDefaultFieldPath(FieldTypeDescriptor fieldType) { return mainIndex.binding().fieldWithProjectionDisabledModels.get( fieldType ).relativeFieldName; } - private F getFieldValue(int documentNumber) { + private F getFieldValue(int documentNumber, FieldTypeDescriptor fieldType) { return getFieldValue( fieldType, documentNumber ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeIndependentIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeIndependentIT.java index e310736c0f4..20c17525eb2 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeIndependentIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/FieldProjectionTypeIndependentIT.java @@ -14,14 +14,14 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to behavior independent from the field type @@ -30,20 +30,20 @@ * Behavior that is specific to the field type is tested elsewhere, * e.g. {@link FieldProjectionSingleValuedBaseIT} and {@link FieldProjectionTypeCheckingAndConversionIT}. */ -public class FieldProjectionTypeIndependentIT { +class FieldProjectionTypeIndependentIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void unknownField() { + void unknownField() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.projection() @@ -58,7 +58,7 @@ public void unknownField() { } @Test - public void nullClass() { + void nullClass() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.projection() @@ -73,7 +73,7 @@ public void nullClass() { } @Test - public void objectField_nested() { + void objectField_nested() { String fieldPath = index.binding().nestedObject.relativeFieldName; StubMappingScope scope = index.createScope(); @@ -85,7 +85,7 @@ public void objectField_nested() { } @Test - public void objectField_flattened() { + void objectField_flattened() { String fieldPath = index.binding().flattenedObject.relativeFieldName; StubMappingScope scope = index.createScope(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/IdentifierProjectionBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/IdentifierProjectionBaseIT.java index 16b11922ea5..35bf4085816 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/IdentifierProjectionBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/IdentifierProjectionBaseIT.java @@ -20,20 +20,20 @@ import org.hibernate.search.engine.backend.types.converter.FromDocumentValueConverter; import org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentValueConvertContext; import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IdentifierProjectionBaseIT { +class IdentifierProjectionBaseIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "my-index" ); @@ -56,14 +56,14 @@ public IdentifierProjectionBaseIT() { initValues(); } - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndexes( index, compatibleIndex, incompatibleIndex ).setup(); initData(); } @Test - public void simple() { + void simple() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() .select( f -> f.id( String.class ) ) @@ -75,7 +75,7 @@ public void simple() { } @Test - public void noClass() { + void noClass() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() .select( f -> f.id() ) @@ -87,7 +87,7 @@ public void noClass() { } @Test - public void duplicated() { + void duplicated() { StubMappingScope scope = index.createScope(); SearchQuery> query = scope.query() @@ -100,7 +100,7 @@ public void duplicated() { } @Test - public void validSuperClass() { + void validSuperClass() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() .select( f -> f.id( CharSequence.class ) ) @@ -112,7 +112,7 @@ public void validSuperClass() { } @Test - public void invalidProjectionType() { + void invalidProjectionType() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.projection().id( Integer.class ) ) @@ -123,7 +123,7 @@ public void invalidProjectionType() { } @Test - public void multiIndex_withCompatibleIndex() { + void multiIndex_withCompatibleIndex() { StubMappingScope scope = index.createScope( compatibleIndex ); SearchQuery query = scope.query() .select( f -> f.id( String.class ) ) @@ -139,7 +139,7 @@ public void multiIndex_withCompatibleIndex() { } @Test - public void multiIndex_withIncompatibleIndex() { + void multiIndex_withIncompatibleIndex() { StubMappingScope scope = index.createScope( incompatibleIndex ); assertThatThrownBy( () -> scope.projection().id() ) @@ -151,7 +151,7 @@ public void multiIndex_withIncompatibleIndex() { } @Test - public void nullClass() { + void nullClass() { StubMappingScope scope = index.createScope(); assertThatThrownBy( () -> scope.projection().id( (Class) null ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionBaseIT.java index 6c8eea1aba2..d2d32fcf727 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionBaseIT.java @@ -18,25 +18,24 @@ import org.hibernate.search.engine.search.projection.dsl.CompositeProjectionInnerStep; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; -@RunWith(NestedRunner.class) -public class ObjectProjectionBaseIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class ObjectProjectionBaseIT { + //CHECKSTYLE:ON - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( FromAsIT.index ).setup(); BulkIndexer fromAsIndexer = FromAsIT.index.bulkIndexer(); @@ -45,11 +44,6 @@ public static void setup() { fromAsIndexer.join(); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - private static ObjectStructure requiredObjectStructure(boolean multivalued) { return multivalued && TckConfiguration.get().getBackendFeatures().reliesOnNestedDocumentsForMultiValuedObjectProjection() @@ -58,7 +52,7 @@ private static ObjectStructure requiredObjectStructure(boolean multivalued) { } @Nested - public static class FromAsIT extends AbstractCompositeProjectionFromAsIT { + class FromAsIT extends AbstractCompositeProjectionFromAsIT { private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "fromAs" ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionSpecificsIT.java index b7911a5ae5d..eb9deb105c0 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/ObjectProjectionSpecificsIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.backend.tck.search.projection; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.hibernate.search.engine.backend.document.IndexFieldReference; import org.hibernate.search.engine.backend.document.IndexObjectFieldReference; @@ -17,50 +17,50 @@ import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ObjectProjectionSpecificsIT { +class ObjectProjectionSpecificsIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( index ) .setup(); } @Test - public void nullFieldPath() { + void nullFieldPath() { assertThatThrownBy( () -> index.createScope().projection().object( null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContaining( "'objectFieldPath' must not be null" ); } @Test - public void unknownFieldPath() { + void unknownFieldPath() { assertThatThrownBy( () -> index.createScope().projection().object( "unknownField" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Unknown field 'unknownField'" ); } @Test - public void nonObjectFieldPath() { + void nonObjectFieldPath() { assertThatThrownBy( () -> index.createScope().projection().object( "level1.field1" ) ) .hasMessageContainingAll( "Cannot use 'projection:object' on field 'level1.field1'" ); } @Test - public void innerObjectProjectionOnFieldOutsideOuterObjectProjectionFieldTree() { + void innerObjectProjectionOnFieldOutsideOuterObjectProjectionFieldTree() { assertThatThrownBy( () -> index.query() .select( f -> f.object( "level1.level2" ) .from( @@ -85,10 +85,10 @@ public void innerObjectProjectionOnFieldOutsideOuterObjectProjectionFieldTree() } @Test - public void multiValuedObjectField_flattened_unsupported() { + void multiValuedObjectField_flattened_unsupported() { assumeTrue( - "This test is only relevant if the backend relies on nested documents to implement object projections on multi-valued fields", - TckConfiguration.get().getBackendFeatures().reliesOnNestedDocumentsForMultiValuedObjectProjection() + TckConfiguration.get().getBackendFeatures().reliesOnNestedDocumentsForMultiValuedObjectProjection(), + "This test is only relevant if the backend relies on nested documents to implement object projections on multi-valued fields" ); SearchProjectionFactory f = index.createScope().projection(); assertThatThrownBy( () -> f.object( "flattenedLevel1" ) ) @@ -101,7 +101,7 @@ public void multiValuedObjectField_flattened_unsupported() { } @Test - public void multiValuedObjectField_singleValuedObjectProjection() { + void multiValuedObjectField_singleValuedObjectProjection() { SearchProjectionFactory f = index.createScope().projection(); assertThatThrownBy( () -> f.object( "level1" ) .from( f.field( "level1.field1" ) ) @@ -118,7 +118,7 @@ public void multiValuedObjectField_singleValuedObjectProjection() { } @Test - public void singleValuedObjectField_effectivelyMultiValuedInContext() { + void singleValuedObjectField_effectivelyMultiValuedInContext() { assertThatThrownBy( () -> index.query() .select( f -> f.object( "level1WithSingleValuedLevel2.level2" ) .from( f.field( "level1WithSingleValuedLevel2.level2.field1" ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/SearchProjectionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/SearchProjectionIT.java index bea334c126b..060ecb2e3bb 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/SearchProjectionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/SearchProjectionIT.java @@ -41,27 +41,30 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; import org.hibernate.search.integrationtest.backend.tck.testsupport.stub.StubEntity; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.StandardFieldMapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.GenericStubMappingScope; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; /** * Generic tests for projections. More specific tests can be found in other classes, such as {@link FieldProjectionSingleValuedBaseIT}. */ +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings("unchecked") // Mocking parameterized types -public class SearchProjectionIT { +class SearchProjectionIT { private static final String DOCUMENT_1 = "1"; private static final String DOCUMENT_2 = "2"; @@ -70,11 +73,8 @@ public class SearchProjectionIT { private static final ProjectionMappedTypeContext mainTypeContextMock = Mockito.mock( ProjectionMappedTypeContext.class ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -83,15 +83,15 @@ public class SearchProjectionIT { // What matters here is that is a different index. SimpleMappedIndex.of( IndexBinding::new ).name( "other" ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndexes( mainIndex, otherIndex ).setup(); initData(); } @Test - public void noProjections() { + void noProjections() { StubMappingScope scope = mainIndex.createScope(); SearchQuery> query = scope.query() @@ -103,7 +103,7 @@ public void noProjections() { } @Test - public void references_noLoadingContext() { + void references_noLoadingContext() { StubMappingScope scope = mainIndex.createScope(); SearchQuery> query; @@ -138,7 +138,7 @@ public void references_noLoadingContext() { @Test @TestForIssue(jiraKey = "HSEARCH-3395") - public void references() { + void references() { DocumentReference document1Reference = reference( mainIndex.typeName(), DOCUMENT_1 ); DocumentReference document2Reference = reference( mainIndex.typeName(), DOCUMENT_2 ); DocumentReference document3Reference = reference( mainIndex.typeName(), DOCUMENT_3 ); @@ -208,7 +208,7 @@ public void references() { } @Test - public void score() { + void score() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -233,7 +233,7 @@ public void score() { * Test projection on the score when we do not sort by score. */ @Test - public void score_noScoreSort() { + void score_noScoreSort() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query = scope.query() @@ -253,7 +253,7 @@ public void score_noScoreSort() { } @Test - public void constant_nonNull() { + void constant_nonNull() { StubMappingScope scope = mainIndex.createScope(); String constantValue = "foo"; @@ -282,7 +282,7 @@ public void constant_nonNull() { } @Test - public void constant_null() { + void constant_null() { StubMappingScope scope = mainIndex.createScope(); assertThatQuery( scope.query() @@ -310,7 +310,7 @@ public void constant_null() { } @Test - public void constant_root() { + void constant_root() { StubMappingScope scope = mainIndex.createScope(); String constantValue = "foo"; @@ -331,7 +331,7 @@ public void constant_root() { * and also multiple field projections. */ @Test - public void mixed() { + void mixed() { StubMappingScope scope = mainIndex.createScope(); SearchQuery> query; @@ -374,7 +374,7 @@ public void mixed() { * and also multiple field projections, using nested fields too. */ @Test - public void mixed_withNestedFields() { + void mixed_withNestedFields() { StubMappingScope scope = mainIndex.createScope(); SearchQuery> query; @@ -423,7 +423,7 @@ public void mixed_withNestedFields() { } @Test - public void reuseProjectionInstance_onScopeTargetingSameIndexes() { + void reuseProjectionInstance_onScopeTargetingSameIndexes() { StubMappingScope scope = mainIndex.createScope(); SearchProjection projection = scope.projection() .field( mainIndex.binding().string1Field.relativeFieldName, String.class ).toProjection(); @@ -470,7 +470,7 @@ public void reuseProjectionInstance_onScopeTargetingSameIndexes() { } @Test - public void reuseProjectionInstance_onScopeTargetingDifferentIndexes() { + void reuseProjectionInstance_onScopeTargetingDifferentIndexes() { StubMappingScope scope = mainIndex.createScope(); SearchProjection projection = scope.projection() .field( mainIndex.binding().string1Field.relativeFieldName, String.class ).toProjection(); @@ -500,7 +500,7 @@ public void reuseProjectionInstance_onScopeTargetingDifferentIndexes() { } @Test - public void extension() { + void extension() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query; @@ -581,21 +581,21 @@ public void extension() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath() { + void toAbsolutePath() { assertThat( mainIndex.createScope().projection().toAbsolutePath( "string" ) ) .isEqualTo( "string" ); } @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_withRoot() { + void toAbsolutePath_withRoot() { assertThat( mainIndex.createScope().projection().withRoot( "nested" ).toAbsolutePath( "inner" ) ) .isEqualTo( "nested.inner" ); } @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_null() { + void toAbsolutePath_null() { assertThatThrownBy( () -> mainIndex.createScope().projection().toAbsolutePath( null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContaining( "'relativeFieldPath' must not be null" ); @@ -603,7 +603,7 @@ public void toAbsolutePath_null() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_withRoot_null() { + void toAbsolutePath_withRoot_null() { assertThatThrownBy( () -> mainIndex.createScope().projection().withRoot( "nested" ).toAbsolutePath( null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContaining( "'relativeFieldPath' must not be null" ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/UnsupportedNestingProjectionBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/UnsupportedNestingProjectionBaseIT.java index ae415287001..3501ac2f4ed 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/UnsupportedNestingProjectionBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/projection/UnsupportedNestingProjectionBaseIT.java @@ -14,30 +14,30 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class UnsupportedNestingProjectionBaseIT { +class UnsupportedNestingProjectionBaseIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ) .name( "my-index" ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndexes( index ).setup(); initData(); } @Test - public void id() { + void id() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.id() @@ -54,7 +54,7 @@ public void id() { } @Test - public void entity() { + void entity() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.entity() @@ -71,7 +71,7 @@ public void entity() { } @Test - public void entityReference() { + void entityReference() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.entityReference() @@ -88,7 +88,7 @@ public void entityReference() { } @Test - public void documentReference() { + void documentReference() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.documentReference() @@ -105,7 +105,7 @@ public void documentReference() { } @Test - public void score() { + void score() { assertThatThrownBy( () -> index.createScope().query() .select( f -> f.object( "nested" ).from( f.score() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryBaseIT.java index 89c9a87a61b..d9c91d4c024 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryBaseIT.java @@ -32,31 +32,31 @@ import org.hibernate.search.engine.search.query.dsl.SearchQuerySelectStep; import org.hibernate.search.engine.search.query.dsl.SearchQueryWhereStep; import org.hibernate.search.engine.search.query.spi.SearchQueryIndexScope; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubSearchLoadingContext; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchQueryBaseIT { +class SearchQueryBaseIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void getQueryString() { + void getQueryString() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() @@ -68,7 +68,7 @@ public void getQueryString() { @Test @TestForIssue(jiraKey = "HSEARCH-4183") - public void tookAndTimedOut() { + void tookAndTimedOut() { SearchQuery query = matchAllSortedByScoreQuery() .toQuery(); @@ -79,7 +79,7 @@ public void tookAndTimedOut() { } @Test - public void resultTotal() { + void resultTotal() { initData( 5000 ); SearchResult fetch = matchAllSortedByScoreQuery() @@ -93,7 +93,7 @@ public void resultTotal() { } @Test - public void resultTotal_totalHitCountThreshold() { + void resultTotal_totalHitCountThreshold() { initData( 5000 ); SearchResult fetch = matchAllWithConditionSortedByScoreQuery() @@ -116,7 +116,7 @@ public void resultTotal_totalHitCountThreshold() { } @Test - public void resultTotal_totalHitCountThreshold_veryHigh() { + void resultTotal_totalHitCountThreshold_veryHigh() { initData( 5000 ); SearchResult fetch = matchAllWithConditionSortedByScoreQuery() @@ -132,7 +132,7 @@ public void resultTotal_totalHitCountThreshold_veryHigh() { } @Test - public void extension() { + void extension() { initData( 2 ); SearchQuery query = matchAllSortedByScoreQuery().toQuery(); @@ -150,7 +150,7 @@ public void extension() { } @Test - public void context_extension() { + void context_extension() { initData( 5 ); StubMappingScope scope = index.createScope(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryFetchIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryFetchIT.java index 20990a352b9..bb7c1a64677 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryFetchIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryFetchIT.java @@ -25,34 +25,34 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchQueryFetchIT { +class SearchQueryFetchIT { private static final int DOCUMENT_COUNT = 200; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void fetchAll() { + void fetchAll() { assertThatResult( matchAllQuerySortByField().fetchAll() ) .hasTotalHitCount( DOCUMENT_COUNT ) .hasDocRefHitsExactOrder( builder -> { @@ -71,7 +71,7 @@ public void fetchAll() { } @Test - public void fetch_limit() { + void fetch_limit() { assertThatResult( matchAllQuerySortByField().fetch( null ) ) .hasTotalHitCount( DOCUMENT_COUNT ) .hasDocRefHitsExactOrder( builder -> { @@ -90,7 +90,7 @@ public void fetch_limit() { } @Test - public void fetch_offset_limit() { + void fetch_offset_limit() { assertThatResult( matchAllQuerySortByField().fetch( 1, null ) ) .hasTotalHitCount( DOCUMENT_COUNT ) .hasDocRefHitsExactOrder( builder -> { @@ -122,7 +122,7 @@ public void fetch_offset_limit() { } @Test - public void fetch_offset_limit_exceedsMaxValue() { + void fetch_offset_limit_exceedsMaxValue() { assertThatThrownBy( () -> matchAllQuerySortByField().fetch( 1, Integer.MAX_VALUE ) ) // error message will depend on the specific backend .isInstanceOf( SearchException.class ); @@ -135,7 +135,7 @@ public void fetch_offset_limit_exceedsMaxValue() { */ @Test @TestForIssue(jiraKey = "HSEARCH-4019") - public void fetch_offset_limit_defaultSort() { + void fetch_offset_limit_defaultSort() { assertThatResult( matchAllQuerySortByDefault().fetch( 1, null ) ) .hasTotalHitCount( DOCUMENT_COUNT ) .hasDocRefHitsAnyOrder( builder -> { @@ -167,7 +167,7 @@ public void fetch_offset_limit_defaultSort() { } @Test - public void fetchAllHits() { + void fetchAllHits() { assertThatHits( matchAllQuerySortByField().fetchAllHits() ) .hasDocRefHitsExactOrder( builder -> { for ( int i = 0; i < DOCUMENT_COUNT; i++ ) { @@ -184,7 +184,7 @@ public void fetchAllHits() { } @Test - public void fetchHits_limit() { + void fetchHits_limit() { assertThatHits( matchAllQuerySortByField().fetchHits( null ) ) .hasDocRefHitsExactOrder( builder -> { for ( int i = 0; i < DOCUMENT_COUNT; i++ ) { @@ -200,7 +200,7 @@ public void fetchHits_limit() { } @Test - public void fetchHits_offset_limit_fieldSort() { + void fetchHits_offset_limit_fieldSort() { assertThatHits( matchAllQuerySortByField().fetchHits( 1, null ) ) .hasDocRefHitsExactOrder( builder -> { for ( int i = 1; i < DOCUMENT_COUNT; i++ ) { @@ -233,7 +233,7 @@ public void fetchHits_offset_limit_fieldSort() { */ @Test @TestForIssue(jiraKey = "HSEARCH-4019") - public void fetchHits_offset_limit_defaultSort() { + void fetchHits_offset_limit_defaultSort() { assertThatHits( matchAllQuerySortByDefault().fetchHits( 1, null ) ) .hasDocRefHitsAnyOrder( builder -> { for ( int i = 1; i < DOCUMENT_COUNT; i++ ) { @@ -260,7 +260,7 @@ public void fetchHits_offset_limit_defaultSort() { } @Test - public void fetchTotalHitCount() { + void fetchTotalHitCount() { assertThat( matchAllQuerySortByField().fetchTotalHitCount() ).isEqualTo( DOCUMENT_COUNT ); assertThat( matchAllQuerySortByField().toQuery().fetchTotalHitCount() ).isEqualTo( DOCUMENT_COUNT ); @@ -270,7 +270,7 @@ public void fetchTotalHitCount() { @Test @TestForIssue(jiraKey = "HSEARCH-3511") - public void fetchTotalHitCount_offset_limit() { + void fetchTotalHitCount_offset_limit() { SearchQuery query = matchAllQuerySortByField().toQuery(); // Using an offset/limit should not affect later counts @@ -282,7 +282,7 @@ public void fetchTotalHitCount_offset_limit() { } @Test - public void fetchTotalHitCount_withProjection() { + void fetchTotalHitCount_withProjection() { assertThat( index.query() .select( f -> f.field( "integer", Integer.class ) ) .where( f -> f.matchAll() ) @@ -309,7 +309,7 @@ public void fetchTotalHitCount_withProjection() { } @Test - public void fetchSingleHit() { + void fetchSingleHit() { Optional result = matchOneQuery( 4 ).fetchSingleHit(); assertThat( result ).isNotEmpty(); assertThat( normalize( result.get() ) ) @@ -325,7 +325,7 @@ public void fetchSingleHit() { } @Test - public void fetch_limitAndOffset_reuseQuery() { + void fetch_limitAndOffset_reuseQuery() { SearchQuery query = matchAllQuerySortByField().toQuery(); assertThatResult( query.fetch( 1, null ) ).fromQuery( query ) .hasTotalHitCount( DOCUMENT_COUNT ) @@ -362,7 +362,7 @@ public void fetch_limitAndOffset_reuseQuery() { @Test @TestForIssue(jiraKey = "HSEARCH-3389") - public void maxResults_zero() { + void maxResults_zero() { assertThatResult( matchAllQuerySortByField().fetch( 0, 0 ) ) .hasTotalHitCount( DOCUMENT_COUNT ) .hasNoHits(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryLoadingOptionsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryLoadingOptionsIT.java index 8e1bf782fba..5be9ae31e39 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryLoadingOptionsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryLoadingOptionsIT.java @@ -19,41 +19,41 @@ import org.hibernate.search.engine.search.loading.spi.SearchLoadingContext; import org.hibernate.search.engine.search.projection.spi.ProjectionMappedTypeContext; import org.hibernate.search.integrationtest.backend.tck.testsupport.stub.StubEntity; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.GenericStubMappingScope; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @TestForIssue(jiraKey = "HSEARCH-3988") @SuppressWarnings("unchecked") // Mocking parameterized types -public class SearchQueryLoadingOptionsIT { +class SearchQueryLoadingOptionsIT { private static final ProjectionMappedTypeContext typeContextMock = Mockito.mock( ProjectionMappedTypeContext.class ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void defaultResultType() { + void defaultResultType() { SearchLoadingContext loadingContextMock = mock( SearchLoadingContext.class ); Consumer loadingOptionsStepMock = mock( Consumer.class ); @@ -76,7 +76,7 @@ public void defaultResultType() { } @Test - public void selectEntity() { + void selectEntity() { SearchLoadingContext loadingContextMock = mock( SearchLoadingContext.class ); Consumer loadingOptionsStepMock = mock( Consumer.class ); @@ -100,7 +100,7 @@ public void selectEntity() { } @Test - public void selectEntityReference() { + void selectEntityReference() { SearchLoadingContext loadingContextMock = mock( SearchLoadingContext.class ); Consumer loadingOptionsStepMock = mock( Consumer.class ); @@ -122,7 +122,7 @@ public void selectEntityReference() { } @Test - public void select() { + void select() { SearchLoadingContext loadingContextMock = mock( SearchLoadingContext.class ); Consumer loadingOptionsStepMock = mock( Consumer.class ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryScrollIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryScrollIT.java index 2ad275b9115..8a80cf90fff 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryScrollIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryScrollIT.java @@ -10,9 +10,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchHitsAssert.assertThatHits; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; import java.util.Locale; @@ -26,34 +24,34 @@ import org.hibernate.search.engine.search.query.SearchScrollResult; import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchQueryScrollIT { +class SearchQueryScrollIT { private static final int DOCUMENT_COUNT = 2000; private static final int CHUNK_SIZE = 30; private static final int EXACT_DIVISOR_CHUNK_SIZE = 25; - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void none() { + void none() { try ( SearchScroll scroll = matchNoneQuery().scroll( CHUNK_SIZE ) ) { SearchScrollResult scrollResult = scroll.next(); assertThat( scrollResult.hasHits() ).isFalse(); @@ -63,7 +61,7 @@ public void none() { } @Test - public void one() { + void one() { try ( SearchScroll scroll = matchOneQuery( 4 ).scroll( CHUNK_SIZE ) ) { SearchScrollResult scrollResult = scroll.next(); assertThat( scrollResult.hasHits() ).isTrue(); @@ -77,52 +75,52 @@ public void one() { } @Test - public void all() { + void all() { try ( SearchScroll scroll = matchAllQuery().scroll( CHUNK_SIZE ) ) { checkScrolling( scroll, DOCUMENT_COUNT, CHUNK_SIZE ); } } @Test - public void all_exactDivisorPageSize() { + void all_exactDivisorPageSize() { try ( SearchScroll scroll = matchAllQuery().scroll( EXACT_DIVISOR_CHUNK_SIZE ) ) { checkScrolling( scroll, DOCUMENT_COUNT, EXACT_DIVISOR_CHUNK_SIZE ); } } @Test - public void firstHalf() { + void firstHalf() { try ( SearchScroll scroll = matchFirstHalfQuery().scroll( CHUNK_SIZE ) ) { checkScrolling( scroll, DOCUMENT_COUNT / 2, CHUNK_SIZE ); } } @Test - public void firstHalf_onePage() { + void firstHalf_onePage() { try ( SearchScroll scroll = matchFirstHalfQuery().scroll( DOCUMENT_COUNT / 2 ) ) { checkScrolling( scroll, DOCUMENT_COUNT / 2, DOCUMENT_COUNT / 2 ); } } @Test - public void firstHalf_largerPage() { + void firstHalf_largerPage() { try ( SearchScroll scroll = matchFirstHalfQuery().scroll( DOCUMENT_COUNT / 2 + 10 ) ) { checkScrolling( scroll, DOCUMENT_COUNT / 2, DOCUMENT_COUNT / 2 ); } } @Test - public void tookAndTimedOut() { + void tookAndTimedOut() { try ( SearchScroll scroll = matchAllQuery().scroll( CHUNK_SIZE ) ) { SearchScrollResult result = scroll.next(); - assertNotNull( result.took() ); - assertFalse( result.timedOut() ); + assertThat( result.took() ).isNotNull(); + assertThat( result.timedOut() ).isFalse(); } } @Test - public void resultTotal() { + void resultTotal() { try ( SearchScroll scroll = matchAllWithConditionSortedByScoreQuery() .scroll( CHUNK_SIZE ) ) { for ( SearchScrollResult chunk = scroll.next(); chunk.hasHits(); @@ -138,10 +136,10 @@ public void resultTotal() { } @Test - public void resultTotal_totalHitCountThreshold() { + void resultTotal_totalHitCountThreshold() { assumeTrue( - "This backend doesn't take totalHitsThreshold() into account for scrolls.", - TckConfiguration.get().getBackendFeatures().supportsTotalHitsThresholdForScroll() + TckConfiguration.get().getBackendFeatures().supportsTotalHitsThresholdForScroll(), + "This backend doesn't take totalHitsThreshold() into account for scrolls." ); try ( SearchScroll scroll = matchAllWithConditionSortedByScoreQuery() @@ -200,10 +198,10 @@ public void resultTotal_totalHitCountThreshold() { } @Test - public void resultTotal_totalHitCountThreshold_veryHigh() { + void resultTotal_totalHitCountThreshold_veryHigh() { assumeTrue( - "This backend doesn't take totalHitsThreshold() into account for scrolls.", - TckConfiguration.get().getBackendFeatures().supportsTotalHitsThresholdForScroll() + TckConfiguration.get().getBackendFeatures().supportsTotalHitsThresholdForScroll(), + "This backend doesn't take totalHitsThreshold() into account for scrolls." ); try ( SearchScroll scroll = matchAllWithConditionSortedByScoreQuery() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryScrollResultLoadingIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryScrollResultLoadingIT.java index 03fe2640703..144356ded2f 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryScrollResultLoadingIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryScrollResultLoadingIT.java @@ -27,25 +27,27 @@ import org.hibernate.search.engine.search.query.SearchScroll; import org.hibernate.search.engine.search.query.SearchScrollResult; import org.hibernate.search.integrationtest.backend.tck.testsupport.stub.StubEntity; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.GenericStubMappingScope; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class SearchQueryScrollResultLoadingIT { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class SearchQueryScrollResultLoadingIT { - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final ProjectionMappedTypeContext typeContextMock = Mockito.mock( ProjectionMappedTypeContext.class ); @@ -53,11 +55,8 @@ public class SearchQueryScrollResultLoadingIT { private static final IndexItem[] references = new IndexItem[37]; - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -70,7 +69,7 @@ public static void setup() { } @Test - public void resultLoadingOnScrolling() { + void resultLoadingOnScrolling() { @SuppressWarnings("unchecked") SearchLoadingContext loadingContextMock = mock( SearchLoadingContext.class ); @@ -92,7 +91,7 @@ public void resultLoadingOnScrolling() { } @Test - public void resultLoadingOnScrolling_entityLoadingTimeout() { + void resultLoadingOnScrolling_entityLoadingTimeout() { @SuppressWarnings("unchecked") SearchLoadingContext loadingContextMock = mock( SearchLoadingContext.class ); @@ -116,7 +115,7 @@ public void resultLoadingOnScrolling_entityLoadingTimeout() { } @Test - public void resultLoadingOnScrolling_softTimeout() { + void resultLoadingOnScrolling_softTimeout() { @SuppressWarnings("unchecked") SearchLoadingContext loadingContextMock = mock( SearchLoadingContext.class ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQuerySelectIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQuerySelectIT.java index da8c26d2d7e..b2310864f90 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQuerySelectIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQuerySelectIT.java @@ -11,23 +11,22 @@ import org.hibernate.search.integrationtest.backend.tck.search.projection.AbstractEntityProjectionIT; import org.hibernate.search.integrationtest.backend.tck.search.projection.AbstractEntityReferenceProjectionIT; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.extension.RegisterExtension; -@RunWith(NestedRunner.class) -public class SearchQuerySelectIT { +//CHECKSTYLE:OFF HideUtilityClassConstructor ignore the rule since it is a class with nested test classes. +// cannot make a private constructor. +class SearchQuerySelectIT { + //CHECKSTYLE:ON - @ClassRule - public static final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static final SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex selectEntityMainIndex = SimpleMappedIndex.of( AbstractEntityProjectionIT.IndexBinding::new ).name( "entityMain" ); @@ -42,8 +41,8 @@ public class SearchQuerySelectIT { private static final StubMappedIndex selectEntityReferenceIndex = StubMappedIndex.withoutFields() .name( "entityref" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( selectEntityMainIndex, selectEntityMultiIndex1, selectEntityMultiIndex2, selectEntityMultiIndex3, selectEntityMultiIndex4 ) @@ -68,13 +67,8 @@ public static void setup() { selectEntityReferenceIndexer ); } - @Test - public void takariCpSuiteWorkaround() { - // Workaround to get Takari-CPSuite to run this test. - } - @Nested - public static class SelectDefaultIT extends AbstractEntityProjectionIT { + class SelectDefaultIT extends AbstractEntityProjectionIT { public SelectDefaultIT() { super( selectEntityMainIndex, selectEntityMultiIndex1, selectEntityMultiIndex2, @@ -88,7 +82,7 @@ public SelectDefaultIT() { } @Nested - public static class SelectEntityIT extends AbstractEntityProjectionIT { + class SelectEntityIT extends AbstractEntityProjectionIT { public SelectEntityIT() { super( selectEntityMainIndex, selectEntityMultiIndex1, selectEntityMultiIndex2, selectEntityMultiIndex3, selectEntityMultiIndex4 @@ -102,7 +96,7 @@ public SelectEntityIT() { } @Nested - public static class SelectEntityReferenceIT extends AbstractEntityReferenceProjectionIT { + class SelectEntityReferenceIT extends AbstractEntityReferenceProjectionIT { public SelectEntityReferenceIT() { super( selectEntityReferenceIndex ); } @@ -118,7 +112,7 @@ public SelectEntityReferenceIT() { // so we need to test them separately. @Nested - public static class SelectDefaultWithExtensionIT extends AbstractEntityProjectionIT { + class SelectDefaultWithExtensionIT extends AbstractEntityProjectionIT { public SelectDefaultWithExtensionIT() { super( selectEntityMainIndex, selectEntityMultiIndex1, selectEntityMultiIndex2, selectEntityMultiIndex3, selectEntityMultiIndex4 @@ -132,7 +126,7 @@ public SelectDefaultWithExtensionIT() { } @Nested - public static class SelectEntityWithExtensionIT extends AbstractEntityProjectionIT { + class SelectEntityWithExtensionIT extends AbstractEntityProjectionIT { public SelectEntityWithExtensionIT() { super( selectEntityMainIndex, selectEntityMultiIndex1, selectEntityMultiIndex2, selectEntityMultiIndex3, selectEntityMultiIndex4 @@ -147,7 +141,7 @@ public SelectEntityWithExtensionIT() { } @Nested - public static class SelectEntityReferenceWithExtensionIT extends AbstractEntityReferenceProjectionIT { + class SelectEntityReferenceWithExtensionIT extends AbstractEntityReferenceProjectionIT { public SelectEntityReferenceWithExtensionIT() { super( selectEntityReferenceIndex ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryTimeoutIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryTimeoutIT.java index 227c92380e2..1f52c72d4a5 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryTimeoutIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/query/SearchQueryTimeoutIT.java @@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.time.Duration; import java.util.ArrayList; @@ -24,17 +24,17 @@ import org.hibernate.search.engine.search.query.SearchScrollResult; import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.SearchTimeoutException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchQueryTimeoutIT { +class SearchQueryTimeoutIT { private static final String EMPTY_FIELD_NAME = "emptyFieldName"; private static final int NON_MATCHING_INTEGER = 739; @@ -42,13 +42,13 @@ public class SearchQueryTimeoutIT { // Increasing this will increase query execution time. private static final int DOCUMENT_COUNT = 100; - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); index.bulkIndexer() @@ -57,7 +57,7 @@ public static void setup() { } @Test - public void fetch_failAfter_slowQuery_smallTimeout() { + void fetch_failAfter_slowQuery_smallTimeout() { SearchQuery query = startSlowQuery() .failAfter( 1, TimeUnit.NANOSECONDS ) .toQuery(); @@ -68,7 +68,7 @@ public void fetch_failAfter_slowQuery_smallTimeout() { } @Test - public void fetchTotalHitCount_failAfter_slowQuery_smallTimeout() { + void fetchTotalHitCount_failAfter_slowQuery_smallTimeout() { SearchQuery query = startSlowQuery() .failAfter( 1, TimeUnit.NANOSECONDS ) .toQuery(); @@ -79,7 +79,7 @@ public void fetchTotalHitCount_failAfter_slowQuery_smallTimeout() { } @Test - public void scroll_failAfter_slowQuery_smallTimeout() { + void scroll_failAfter_slowQuery_smallTimeout() { SearchQuery query = startSlowQuery() .failAfter( 1, TimeUnit.NANOSECONDS ) .toQuery(); @@ -92,7 +92,7 @@ public void scroll_failAfter_slowQuery_smallTimeout() { } @Test - public void fetch_truncateAfter_slowQuery_smallTimeout() { + void fetch_truncateAfter_slowQuery_smallTimeout() { SearchResult result = startSlowQuery() .truncateAfter( 1, TimeUnit.NANOSECONDS ) .fetch( 20 ); @@ -112,10 +112,10 @@ public void fetch_truncateAfter_slowQuery_smallTimeout() { } @Test - public void scroll_truncateAfter_slowQuery_smallTimeout() { + void scroll_truncateAfter_slowQuery_smallTimeout() { assumeTrue( - "The backend doesn't support truncateAfter() on scrolls", - TckConfiguration.get().getBackendFeatures().supportsTruncateAfterForScroll() + TckConfiguration.get().getBackendFeatures().supportsTruncateAfterForScroll(), + "The backend doesn't support truncateAfter() on scrolls" ); SearchQuery query = startSlowQuery() @@ -134,7 +134,7 @@ public void scroll_truncateAfter_slowQuery_smallTimeout() { } @Test - public void fetch_failAfter_fastQuery_largeTimeout() { + void fetch_failAfter_fastQuery_largeTimeout() { SearchResult result = startFastQuery() .failAfter( 1, TimeUnit.DAYS ) .fetch( 20 ); @@ -146,7 +146,7 @@ public void fetch_failAfter_fastQuery_largeTimeout() { } @Test - public void fetchTotalHitCount_failAfter_fastQuery_largeTimeout() { + void fetchTotalHitCount_failAfter_fastQuery_largeTimeout() { SearchQuery query = startFastQuery() .failAfter( 1, TimeUnit.DAYS ) .toQuery(); @@ -155,7 +155,7 @@ public void fetchTotalHitCount_failAfter_fastQuery_largeTimeout() { } @Test - public void scroll_failAfter_fastQuery_largeTimeout() { + void scroll_failAfter_fastQuery_largeTimeout() { SearchQuery query = startFastQuery() .failAfter( 1, TimeUnit.DAYS ) .toQuery(); @@ -172,7 +172,7 @@ public void scroll_failAfter_fastQuery_largeTimeout() { } @Test - public void fetch_truncateAfter_fastQuery_largeTimeout() { + void fetch_truncateAfter_fastQuery_largeTimeout() { SearchResult result = startFastQuery() .truncateAfter( 1, TimeUnit.DAYS ) .fetch( 20 ); @@ -182,7 +182,7 @@ public void fetch_truncateAfter_fastQuery_largeTimeout() { } @Test - public void scroll_truncateAfter_fastQuery_largeTimeout() { + void scroll_truncateAfter_fastQuery_largeTimeout() { SearchQuery query = startFastQuery() .truncateAfter( 1, TimeUnit.DAYS ) .toQuery(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/CompositeSortIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/CompositeSortIT.java index 4590d34deb5..fb508ec2deb 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/CompositeSortIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/CompositeSortIT.java @@ -24,35 +24,35 @@ import org.hibernate.search.engine.search.sort.dsl.SortFinalStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.KeywordStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class CompositeSortIT { +class CompositeSortIT { private static final String DOCUMENT_1 = "1"; private static final String DOCUMENT_2 = "2"; private static final String DOCUMENT_3 = "3"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void byComposite() { + void byComposite() { SearchQuery query; query = simpleQuery( f -> f.composite( c -> { @@ -85,7 +85,7 @@ public void byComposite() { } @Test - public void byComposite_separateSort() { + void byComposite_separateSort() { StubMappingScope scope = index.createScope(); SearchQuery query; @@ -131,7 +131,7 @@ public void byComposite_separateSort() { } @Test - public void byComposite_empty() { + void byComposite_empty() { SearchQuery query; query = simpleQuery( f -> f.composite() ); @@ -142,7 +142,7 @@ public void byComposite_empty() { } @Test - public void then() { + void then() { SearchQuery query; query = simpleQuery( f -> f @@ -175,7 +175,7 @@ public void then() { } @Test - public void then_flattened_nested() { + void then_flattened_nested() { SearchQuery query; String normalField = index.binding().identicalForFirstTwo.relativeFieldName; @@ -197,7 +197,7 @@ public void then_flattened_nested() { @Test @TestForIssue(jiraKey = "HSEARCH-2254") - public void then_nested_normal_limit1() { + void then_nested_normal_limit1() { SearchQuery query; String normalField = index.binding().identicalForLastTwo.relativeFieldName; @@ -219,7 +219,7 @@ public void then_nested_normal_limit1() { } @Test - public void then_flattened_nested_limit2() { + void then_flattened_nested_limit2() { SearchQuery query; String normalField = index.binding().identicalForFirstTwo.relativeFieldName; @@ -240,7 +240,7 @@ public void then_flattened_nested_limit2() { } @Test - public void then_flattened_nested_filterByPredicate() { + void then_flattened_nested_filterByPredicate() { SearchQuery query; String normalField = index.binding().identicalForFirstTwo.relativeFieldName; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortBaseIT.java index c5a6b05b812..08a6ea4cd8a 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortBaseIT.java @@ -10,8 +10,8 @@ import static org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues.CENTER_POINT; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.Arrays; @@ -36,33 +36,30 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests basic behavior of sorts by distance. */ -@RunWith(Parameterized.class) -public class DistanceSortBaseIT { +class DistanceSortBaseIT { private static final GeoPointFieldTypeDescriptor fieldType = GeoPointFieldTypeDescriptor.INSTANCE; private static final Set> supportedFieldTypes = Collections.singleton( fieldType ); - private static List dataSets; + private static final List dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0} - {2} - {1}") - public static Object[][] parameters() { - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { for ( TestedFieldStructure fieldStructure : TestedFieldStructure.all() ) { // We need two separate datasets when the sort mode is not defined, // because then the sort mode will be inferred automatically to @@ -71,16 +68,19 @@ public static Object[][] parameters() { dataSets.add( dataSetForAsc ); DataSet dataSetForDesc = new DataSet( fieldStructure, null, SortMode.MAX ); dataSets.add( dataSetForDesc ); - parameters.add( new Object[] { fieldStructure, null, dataSetForAsc, dataSetForDesc } ); + parameters.add( Arguments.of( fieldStructure, null, dataSetForAsc, dataSetForDesc ) ); for ( SortMode sortMode : SortMode.values() ) { // When the sort mode is defined, we only need one dataset. dataSetForAsc = new DataSet( fieldStructure, sortMode, sortMode ); dataSets.add( dataSetForAsc ); dataSetForDesc = dataSetForAsc; - parameters.add( new Object[] { fieldStructure, sortMode, dataSetForAsc, dataSetForDesc } ); + parameters.add( Arguments.of( fieldStructure, sortMode, dataSetForAsc, dataSetForDesc ) ); } } - return parameters.toArray( new Object[0][] ); + } + + public static List params() { + return parameters; } private static final int BEFORE_DOCUMENT_1_ORDINAL = 0; @@ -91,16 +91,16 @@ public static Object[][] parameters() { private static final int DOCUMENT_3_ORDINAL = 5; private static final int AFTER_DOCUMENT_3_ORDINAL = 6; - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final Function bindingFactory = root -> SingleFieldIndexBinding.create( root, supportedFieldTypes, c -> c.sortable( Sortable.YES ) ); private static final SimpleMappedIndex index = SimpleMappedIndex.of( bindingFactory ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -110,29 +110,18 @@ public static void setup() { indexer.join(); } - private final TestedFieldStructure fieldStructure; - private final SortMode sortMode; - private final DataSet dataSetForAsc; - private final DataSet dataSetForDesc; - - public DistanceSortBaseIT(TestedFieldStructure fieldStructure, SortMode sortMode, + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") + void simple(TestedFieldStructure fieldStructure, SortMode sortMode, DataSet dataSetForAsc, DataSet dataSetForDesc) { - this.fieldStructure = fieldStructure; - this.sortMode = sortMode; - this.dataSetForAsc = dataSetForAsc; - this.dataSetForDesc = dataSetForDesc; - } - - @Test - public void simple() { - assumeTestParametersWork(); + assumeTestParametersWork( sortMode, fieldStructure ); DataSet dataSet; SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); dataSet = dataSetForAsc; - query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT ) ); + query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT ), sortMode, fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id ); @@ -140,7 +129,9 @@ public void simple() { dataSet = dataSetForAsc; query = simpleQuery( dataSet, - b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) + b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, @@ -150,7 +141,9 @@ public void simple() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc() + .asc(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, @@ -159,7 +152,9 @@ public void simple() { dataSet = dataSetForDesc; query = simpleQuery( dataSet, - b -> b.distance( fieldPath, CENTER_POINT ).desc() + b -> b.distance( fieldPath, CENTER_POINT ).desc(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc3Id, dataSet.doc2Id, @@ -169,27 +164,33 @@ public void simple() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .desc() + .desc(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id ); } - @Test - public void missingValue_explicit() { - assumeTestParametersWork(); + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") + void missingValue_explicit(TestedFieldStructure fieldStructure, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( sortMode, fieldStructure ); DataSet dataSet; SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); // Explicit order with missing().last() dataSet = dataSetForAsc; query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().last() + .asc().missing().last(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, @@ -199,7 +200,9 @@ public void missingValue_explicit() { assertThatThrownBy( () -> simpleQuery( dataSetForDesc, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .desc().missing().last() + .desc().missing().last(), + sortMode, + fieldStructure ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid use of 'missing().last()' for a descending distance sort.", @@ -210,7 +213,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .desc().missing().last() + .desc().missing().last(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id, @@ -222,7 +227,9 @@ public void missingValue_explicit() { assertThatThrownBy( () -> simpleQuery( dataSetForDesc, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .desc().missing().lowest() + .desc().missing().lowest(), + sortMode, + fieldStructure ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid use of 'missing().lowest()' for a descending distance sort.", @@ -231,7 +238,9 @@ public void missingValue_explicit() { assertThatThrownBy( () -> simpleQuery( dataSetForDesc, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().lowest() + .asc().missing().lowest(), + sortMode, + fieldStructure ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid use of 'missing().lowest()' for an ascending distance sort.", @@ -242,7 +251,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().lowest() + .asc().missing().lowest(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc1Id, dataSet.doc2Id, @@ -252,7 +263,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .desc().missing().lowest() + .desc().missing().lowest(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id, @@ -264,7 +277,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .desc().missing().first() + .desc().missing().first(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc3Id, dataSet.doc2Id, @@ -275,7 +290,9 @@ public void missingValue_explicit() { assertThatThrownBy( () -> simpleQuery( dataSetForAsc, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().first() + .asc().missing().first(), + sortMode, + fieldStructure ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid use of 'missing().first()' for an ascending distance sort.", @@ -285,7 +302,9 @@ public void missingValue_explicit() { assertThatThrownBy( () -> simpleQuery( dataSetForAsc, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .missing().first() + .missing().first(), + sortMode, + fieldStructure ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid use of 'missing().first()' for an ascending distance sort.", @@ -296,7 +315,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().first() + .asc().missing().first(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc1Id, dataSet.doc2Id, @@ -308,7 +329,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .desc().missing().highest() + .desc().missing().highest(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc3Id, dataSet.doc2Id, @@ -318,7 +341,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().highest() + .asc().missing().highest(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, @@ -329,7 +354,9 @@ public void missingValue_explicit() { assertThatThrownBy( () -> simpleQuery( dataSetForAsc, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ) + .asc().missing().use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ), + sortMode, + fieldStructure ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid use of 'missing().use(...)' for a distance sort.", @@ -343,7 +370,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ) + .asc().missing().use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc1Id, dataSet.doc2Id, @@ -353,7 +382,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL ) ) + .asc().missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL ) ), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.emptyDoc1Id, dataSet.doc2Id, @@ -363,7 +394,9 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL ) ) + .asc().missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL ) ), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.emptyDoc1Id, @@ -373,24 +406,30 @@ public void missingValue_explicit() { query = simpleQuery( dataSet, b -> b.distance( fieldPath, CENTER_POINT.latitude(), CENTER_POINT.longitude() ) - .asc().missing().use( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL ) ) + .asc().missing().use( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL ) ), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-3103" }) - public void medianWithNestedField() { + void medianWithNestedField(TestedFieldStructure fieldStructure, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { assumeTrue( - "This test is only relevant when using SortMode.MEDIAN in nested fields", - isMedianWithNestedField() + isMedianWithNestedField( sortMode, fieldStructure ), + "This test is only relevant when using SortMode.MEDIAN in nested fields" ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); - assertThatThrownBy( () -> simpleQuery( dataSetForAsc, b -> b.distance( fieldPath, CENTER_POINT ) ) ) + assertThatThrownBy( () -> simpleQuery( dataSetForAsc, b -> b.distance( fieldPath, CENTER_POINT ), sortMode, + fieldStructure + ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid sort mode: MEDIAN", @@ -399,17 +438,21 @@ public void medianWithNestedField() { ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-3103" }) - public void sum() { + void sum(TestedFieldStructure fieldStructure, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { assumeTrue( - "This test is only relevant when using SortMode.SUM", - isSum() + isSum( sortMode ), + "This test is only relevant when using SortMode.SUM" ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); - assertThatThrownBy( () -> simpleQuery( dataSetForAsc, b -> b.distance( fieldPath, CENTER_POINT ) ) ) + assertThatThrownBy( () -> simpleQuery( dataSetForAsc, b -> b.distance( fieldPath, CENTER_POINT ), sortMode, + fieldStructure + ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid sort mode: SUM. This sort mode is not supported for a distance sort", @@ -418,15 +461,19 @@ public void sum() { ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void factoryWithRoot() { - assumeTestParametersWork(); + void factoryWithRoot(TestedFieldStructure fieldStructure, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( sortMode, fieldStructure ); AbstractObjectBinding parentObjectBinding = index.binding().getParentObject( fieldStructure ); - assumeTrue( "This test is only relevant when the field is located on an object field", - parentObjectBinding.absolutePath != null ); + assumeTrue( + parentObjectBinding.absolutePath != null, + "This test is only relevant when the field is located on an object field" + ); DataSet dataSet = dataSetForAsc; assertThatQuery( index.query() @@ -436,7 +483,8 @@ public void factoryWithRoot() { DistanceSortOptionsStep>) f -> f.withRoot( parentObjectBinding.absolutePath ) .distance( parentObjectBinding.getRelativeFieldName( fieldStructure, fieldType ), CENTER_POINT ) ) - .andThen( this::applySortMode ) + .andThen( (DistanceSortOptionsStep optionsStep1) -> applySortMode( optionsStep1, sortMode + ) ) // Don't call this.applyFilter: we need to use the relative name of the discriminator field. .andThen( optionsStep -> { if ( fieldStructure.isInNested() ) { @@ -452,17 +500,21 @@ public void factoryWithRoot() { dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-4513" }) - public void concurrentQueriesUsingSameSort() { - assumeTestParametersWork(); + void concurrentQueriesUsingSameSort(TestedFieldStructure fieldStructure, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( sortMode, fieldStructure ); DataSet dataSet; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure ); StubMappingScope scope = index.createScope(); - SearchSort sort = applyFilter( applySortMode( scope.sort().distance( fieldPath, CENTER_POINT ) ) ).toSort(); + SearchSort sort = applyFilter( applySortMode( scope.sort().distance( fieldPath, CENTER_POINT ), sortMode ), + fieldStructure + ).toSort(); dataSet = dataSetForAsc; SearchQuery query1 = scope.query() @@ -483,31 +535,33 @@ public void concurrentQueriesUsingSameSort() { .hasNoHits(); } - private void assumeTestParametersWork() { + private void assumeTestParametersWork(SortMode sortMode, TestedFieldStructure fieldStructure) { assumeFalse( - "This combination is not expected to work", - isMedianWithNestedField() || isSum() + isMedianWithNestedField( sortMode, fieldStructure ) || isSum( sortMode ), + "This combination is not expected to work" ); } - private boolean isMedianWithNestedField() { + private boolean isMedianWithNestedField(SortMode sortMode, TestedFieldStructure fieldStructure) { return SortMode.MEDIAN.equals( sortMode ) && fieldStructure.isInNested(); } - private boolean isSum() { + private boolean isSum(SortMode sortMode) { return SortMode.SUM.equals( sortMode ); } private SearchQuery simpleQuery(DataSet dataSet, - Function> sortContributor) { + Function> sortContributor, + SortMode sortMode, TestedFieldStructure fieldStructure) { return index.query() .where( f -> f.matchAll() ) .routing( dataSet.routingKey ) - .sort( sortContributor.andThen( this::applySortMode ).andThen( this::applyFilter ) ) + .sort( sortContributor.andThen( t -> applySortMode( t, sortMode ) ) + .andThen( t -> applyFilter( t, fieldStructure ) ) ) .toQuery(); } - private DistanceSortOptionsStep applySortMode(DistanceSortOptionsStep optionsStep) { + private DistanceSortOptionsStep applySortMode(DistanceSortOptionsStep optionsStep, SortMode sortMode) { if ( sortMode != null ) { return optionsStep.mode( sortMode ); } @@ -516,7 +570,8 @@ private SearchQuery simpleQuery(DataSet dataSet, } } - private DistanceSortOptionsStep applyFilter(DistanceSortOptionsStep optionsStep) { + private DistanceSortOptionsStep applyFilter(DistanceSortOptionsStep optionsStep, + TestedFieldStructure fieldStructure) { if ( fieldStructure.isInNested() ) { return optionsStep.filter( f -> f.match() .field( index.binding().getDiscriminatorFieldPath( fieldStructure ) ) @@ -527,7 +582,7 @@ private SearchQuery simpleQuery(DataSet dataSet, } } - private String getFieldPath() { + private String getFieldPath(TestedFieldStructure fieldStructure) { return index.binding().getFieldPath( fieldStructure, fieldType ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortDynamicFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortDynamicFieldIT.java index da46ab378c8..c0725f35531 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortDynamicFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortDynamicFieldIT.java @@ -20,17 +20,17 @@ import org.hibernate.search.engine.search.sort.dsl.SortFinalStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DistanceSortDynamicFieldIT { +class DistanceSortDynamicFieldIT { private static final GeoPointFieldTypeDescriptor fieldType = GeoPointFieldTypeDescriptor.INSTANCE; @@ -44,14 +44,14 @@ public class DistanceSortDynamicFieldIT { private static final int DOCUMENT_2_ORDINAL = 3; private static final int DOCUMENT_3_ORDINAL = 5; - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( mainIndex ) .setup(); @@ -60,7 +60,7 @@ public static void setup() { } @Test - public void simple() { + void simple() { String fieldPath = mainFieldPath(); assertThatQuery( matchNonEmptyQuery( f -> f.distance( fieldPath, CENTER_POINT ).asc() ) ) @@ -71,7 +71,7 @@ public void simple() { @Test @TestForIssue(jiraKey = "HSEARCH-4531") - public void neverPopulated() { + void neverPopulated() { String neverPopulatedFieldPath = neverPopulatedFieldPath(); String mainFieldPath = mainFieldPath(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortFilteringSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortFilteringSpecificsIT.java index 26810b1355b..bc10df8415c 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortFilteringSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortFilteringSpecificsIT.java @@ -21,34 +21,34 @@ import org.hibernate.search.engine.search.sort.dsl.SearchSortFactory; import org.hibernate.search.engine.search.sort.dsl.SortFinalStep; import org.hibernate.search.engine.spatial.GeoPoint; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests behavior related to * {@link org.hibernate.search.engine.search.sort.dsl.SortFilterStep#filter(Function) filtering} * that is not tested in {@link DistanceSortBaseIT}. */ -public class DistanceSortFilteringSpecificsIT { +class DistanceSortFilteringSpecificsIT { - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void nonNested() { + void nonNested() { String fieldPath = index.binding().flattenedObject.relativeFieldName + ".geoPoint"; assertThatThrownBy( @@ -63,7 +63,7 @@ public void nonNested() { } @Test - public void invalidNestedPath_parent() { + void invalidNestedPath_parent() { String fieldPath = index.binding().nestedObject1.relativeFieldName + ".geoPoint"; String fieldInParentPath = "geoPoint"; @@ -80,7 +80,7 @@ public void invalidNestedPath_parent() { } @Test - public void invalidNestedPath_sibling() { + void invalidNestedPath_sibling() { String fieldPath = index.binding().nestedObject1.relativeFieldName + ".geoPoint"; String fieldInSiblingPath = index.binding().nestedObject2.relativeFieldName + ".geoPoint"; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortTypeCheckingAndConversionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortTypeCheckingAndConversionIT.java index 8342a180b2e..ead9b33d454 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortTypeCheckingAndConversionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortTypeCheckingAndConversionIT.java @@ -9,8 +9,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues.CENTER_POINT; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.function.Consumer; import java.util.function.Function; @@ -37,7 +37,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; @@ -45,15 +45,15 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests behavior related to type checking and type conversion of DSL arguments * for sorts by field value. */ -public class DistanceSortTypeCheckingAndConversionIT { +class DistanceSortTypeCheckingAndConversionIT { private static final GeoPointFieldTypeDescriptor fieldType = GeoPointFieldTypeDescriptor.INSTANCE; @@ -72,8 +72,8 @@ public class DistanceSortTypeCheckingAndConversionIT { private static final int DOCUMENT_2_ORDINAL = 3; private static final int DOCUMENT_3_ORDINAL = 5; - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -86,8 +86,8 @@ public class DistanceSortTypeCheckingAndConversionIT { private static final SimpleMappedIndex incompatibleIndex = SimpleMappedIndex.of( IncompatibleIndexBinding::new ).name( "incompatible" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( mainIndex, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex ) .setup(); @@ -96,10 +96,10 @@ public static void setup() { } @Test - public void unsortable() { + void unsortable() { assumeFalse( - "Skipping test for ES GeoPoint as those would become sortable by default in this case.", - TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault() + TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault(), + "Skipping test for ES GeoPoint as those would become sortable by default in this case." ); StubMappingScope scope = mainIndex.createScope(); String fieldPath = getNonSortableFieldPath(); @@ -115,7 +115,7 @@ public void unsortable() { } @Test - public void multiIndex_withCompatibleIndex() { + void multiIndex_withCompatibleIndex() { StubMappingScope scope = mainIndex.createScope( compatibleIndex ); SearchQuery query; @@ -133,7 +133,7 @@ public void multiIndex_withCompatibleIndex() { } @Test - public void multiIndex_withRawFieldCompatibleIndex() { + void multiIndex_withRawFieldCompatibleIndex() { StubMappingScope scope = mainIndex.createScope( rawFieldCompatibleIndex ); SearchQuery query; @@ -152,7 +152,7 @@ public void multiIndex_withRawFieldCompatibleIndex() { @Test @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex() { + void multiIndex_withMissingFieldIndex() { StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); SearchQuery query; @@ -180,10 +180,10 @@ public void multiIndex_withMissingFieldIndex() { */ @Test @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex_nested() { + void multiIndex_withMissingFieldIndex_nested() { assumeTrue( - "This backend doesn't support distance sorts on a nested field that is missing from some of the target indexes.", - TckConfiguration.get().getBackendFeatures().supportsDistanceSortWhenNestedFieldMissingInSomeTargetIndexes() + TckConfiguration.get().getBackendFeatures().supportsDistanceSortWhenNestedFieldMissingInSomeTargetIndexes(), + "This backend doesn't support distance sorts on a nested field that is missing from some of the target indexes." ); StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); @@ -208,7 +208,7 @@ public void multiIndex_withMissingFieldIndex_nested() { } @Test - public void multiIndex_withIncompatibleIndex() { + void multiIndex_withIncompatibleIndex() { StubMappingScope scope = mainIndex.createScope( incompatibleIndex ); String fieldPath = getFieldPath(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortUnsupportedTypesIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortUnsupportedTypesIT.java index 97035dbf7c9..466a57ec2ad 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortUnsupportedTypesIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/DistanceSortUnsupportedTypesIT.java @@ -17,59 +17,52 @@ import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests basic behavior of distance sort common to all unsupported types, * i.e. error messages. */ -@RunWith(Parameterized.class) -public class DistanceSortUnsupportedTypesIT { +class DistanceSortUnsupportedTypesIT { private static Stream> unsupportedTypeDescriptors() { return FieldTypeDescriptor.getAll().stream() .filter( typeDescriptor -> !GeoPoint.class.isAssignableFrom( typeDescriptor.getJavaType() ) ); } - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - List parameters = new ArrayList<>(); + public static List params() { + List parameters = new ArrayList<>(); unsupportedTypeDescriptors().forEach( fieldTypeDescriptor -> { - parameters.add( new Object[] { fieldTypeDescriptor } ); + parameters.add( Arguments.of( fieldTypeDescriptor ) ); } ); - return parameters.toArray( new Object[0][] ); + return parameters; } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldTypeDescriptor; - - public DistanceSortUnsupportedTypesIT(FieldTypeDescriptor fieldTypeDescriptor) { - this.fieldTypeDescriptor = fieldTypeDescriptor; - } - - @Test - public void error_notSupported() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void error_notSupported(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = index.createScope(); - String absoluteFieldPath = getFieldPath(); + String absoluteFieldPath = getFieldPath( fieldTypeDescriptor ); assertThatThrownBy( () -> scope.sort().distance( absoluteFieldPath, GeoPoint.of( 42.0, 45.0 ) ) @@ -84,7 +77,7 @@ public void error_notSupported() { ) ); } - private String getFieldPath() { + private String getFieldPath(FieldTypeDescriptor fieldTypeDescriptor) { return index.binding().fieldModels.get( fieldTypeDescriptor ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortBaseIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortBaseIT.java index 838abd7ef43..4ee84af0b41 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortBaseIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortBaseIT.java @@ -10,8 +10,8 @@ import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchHitsAssert.assertThatHits; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider; -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.time.MonthDay; import java.time.temporal.Temporal; @@ -40,33 +40,29 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.types.NormalizedStringFieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests basic behavior of sorts by field value common to all supported types. */ -@RunWith(Parameterized.class) -public class FieldSortBaseIT { +class FieldSortBaseIT { - private static Set> supportedFieldTypes; - private static List> dataSets; + private static final Set> supportedFieldTypes = new LinkedHashSet<>(); + private static final List> dataSets = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0} - {2} - {1}") - public static Object[][] parameters() { - supportedFieldTypes = new LinkedHashSet<>(); - dataSets = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { for ( FieldTypeDescriptor fieldType : FieldTypeDescriptor.getAll() ) { if ( fieldType.isFieldSortSupported() ) { supportedFieldTypes.add( fieldType ); @@ -78,18 +74,21 @@ public static Object[][] parameters() { dataSets.add( dataSetForAsc ); DataSet dataSetForDesc = new DataSet<>( fieldStructure, fieldType, null, SortMode.MAX ); dataSets.add( dataSetForDesc ); - parameters.add( new Object[] { fieldStructure, fieldType, null, dataSetForAsc, dataSetForDesc } ); + parameters.add( Arguments.of( fieldStructure, fieldType, null, dataSetForAsc, dataSetForDesc ) ); for ( SortMode sortMode : SortMode.values() ) { // When the sort mode is defined, we only need one dataset. dataSetForAsc = new DataSet<>( fieldStructure, fieldType, sortMode, sortMode ); dataSets.add( dataSetForAsc ); dataSetForDesc = dataSetForAsc; - parameters.add( new Object[] { fieldStructure, fieldType, sortMode, dataSetForAsc, dataSetForDesc } ); + parameters.add( Arguments.of( fieldStructure, fieldType, sortMode, dataSetForAsc, dataSetForDesc ) ); } } } } - return parameters.toArray( new Object[0][] ); + } + + public static List params() { + return parameters; } private static final int BEFORE_DOCUMENT_1_ORDINAL = 0; @@ -100,16 +99,16 @@ public static Object[][] parameters() { private static final int DOCUMENT_3_ORDINAL = 5; private static final int AFTER_DOCUMENT_3_ORDINAL = 6; - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final Function bindingFactory = root -> SingleFieldIndexBinding.create( root, supportedFieldTypes, c -> c.sortable( Sortable.YES ) ); private static final SimpleMappedIndex index = SimpleMappedIndex.of( bindingFactory ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); BulkIndexer indexer = index.bulkIndexer(); @@ -119,59 +118,52 @@ public static void setup() { indexer.join(); } - private final TestedFieldStructure fieldStructure; - private final FieldTypeDescriptor fieldType; - private final SortMode sortMode; - private final DataSet dataSetForAsc; - private final DataSet dataSetForDesc; - - public FieldSortBaseIT(TestedFieldStructure fieldStructure, + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") + @TestForIssue(jiraKey = { "HSEARCH-3798", "HSEARCH-2252", "HSEARCH-2254", "HSEARCH-3103" }) + void simple(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType, SortMode sortMode, DataSet dataSetForAsc, DataSet dataSetForDesc) { - this.fieldStructure = fieldStructure; - this.fieldType = fieldType; - this.sortMode = sortMode; - this.dataSetForAsc = dataSetForAsc; - this.dataSetForDesc = dataSetForDesc; - } - - @Test - @TestForIssue(jiraKey = { "HSEARCH-3798", "HSEARCH-2252", "HSEARCH-2254", "HSEARCH-3103" }) - public void simple() { - assumeTestParametersWork(); + assumeTestParametersWork( fieldStructure, fieldType, sortMode ); DataSet dataSet; SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); // Default order dataSet = dataSetForAsc; - query = matchNonEmptyQuery( dataSet, b -> b.field( fieldPath ) ); + query = matchNonEmptyQuery( dataSet, b -> b.field( fieldPath ), sortMode, fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id ); // Explicit order dataSet = dataSetForAsc; - query = matchNonEmptyQuery( dataSet, b -> b.field( fieldPath ).asc() ); + query = matchNonEmptyQuery( dataSet, b -> b.field( fieldPath ).asc(), sortMode, fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id ); dataSet = dataSetForDesc; - query = matchNonEmptyQuery( dataSet, b -> b.field( fieldPath ).desc() ); + query = matchNonEmptyQuery( dataSet, b -> b.field( fieldPath ).desc(), sortMode, fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-3103" }) - public void medianWithNestedField() { + void medianWithNestedField(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { assumeTrue( - "This test is only relevant when using SortMode.MEDIAN in nested fields", - isMedianWithNestedField() && !isSumOrAvgOrMedianWithStringField() + isMedianWithNestedField( sortMode, fieldStructure ) + && !isSumOrAvgOrMedianWithStringField( sortMode, fieldType ), + "This test is only relevant when using SortMode.MEDIAN in nested fields" ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); - assertThatThrownBy( () -> matchNonEmptyQuery( dataSetForAsc, b -> b.field( fieldPath ) ) ) + assertThatThrownBy( () -> matchNonEmptyQuery( dataSetForAsc, b -> b.field( fieldPath ), sortMode, + fieldStructure + ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid sort mode: MEDIAN", @@ -180,17 +172,22 @@ public void medianWithNestedField() { ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-3103" }) - public void sumOrAvgOrMedianWithStringField() { + void sumOrAvgOrMedianWithStringField(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { assumeTrue( - "This test is only relevant when using SortMode.SUM/AVG/MEDIAN on String fields", - isSumOrAvgOrMedianWithStringField() + isSumOrAvgOrMedianWithStringField( sortMode, fieldType ), + "This test is only relevant when using SortMode.SUM/AVG/MEDIAN on String fields" ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); - assertThatThrownBy( () -> matchNonEmptyQuery( dataSetForAsc, b -> b.field( fieldPath ) ) ) + assertThatThrownBy( () -> matchNonEmptyQuery( dataSetForAsc, b -> b.field( fieldPath ), sortMode, + fieldStructure + ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid sort mode: " + sortMode.name() + ". This sort mode is not supported for String fields", @@ -199,17 +196,22 @@ public void sumOrAvgOrMedianWithStringField() { ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-3103" }) - public void sumWithTemporalField() { + void sumWithTemporalField(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { assumeTrue( - "This test is only relevant when using SortMode.SUM on Temporal fields", - isSumWithTemporalField() + isSumWithTemporalField( sortMode, fieldType ), + "This test is only relevant when using SortMode.SUM on Temporal fields" ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); - assertThatThrownBy( () -> matchNonEmptyQuery( dataSetForAsc, b -> b.field( fieldPath ) ) ) + assertThatThrownBy( () -> matchNonEmptyQuery( dataSetForAsc, b -> b.field( fieldPath ), sortMode, + fieldStructure + ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( "Invalid sort mode: SUM. This sort mode is not supported for temporal fields", @@ -218,90 +220,108 @@ public void sumWithTemporalField() { ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3886") - public void missingValue_default() { - assumeTestParametersWork(); + void missingValue_default(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( fieldStructure, fieldType, sortMode ); DataSet dataSet; SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); // Default for missing values is last, regardless of the order dataSet = dataSetForAsc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ) ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ), sortMode, fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id ); dataSet = dataSetForAsc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc(), sortMode, fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id ); dataSet = dataSetForDesc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc(), sortMode, fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id, dataSet.emptyDoc1Id ); } - @Test - public void missingValue_explicit() { - assumeTestParametersWork(); + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") + void missingValue_explicit(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( fieldStructure, fieldType, sortMode ); DataSet dataSet; SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); // Explicit order with missing().last() dataSet = dataSetForAsc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc().missing().last() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc().missing().last(), sortMode, + fieldStructure + ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id ); dataSet = dataSetForDesc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().last() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().last(), sortMode, + fieldStructure + ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id, dataSet.emptyDoc1Id ); // Explicit order with missing().first() dataSet = dataSetForAsc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc().missing().first() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc().missing().first(), sortMode, + fieldStructure + ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id ); dataSet = dataSetForDesc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().first() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().first(), sortMode, + fieldStructure + ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id ); // Explicit order with missing().lowest() dataSet = dataSetForAsc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc().missing().lowest() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc().missing().lowest(), sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id ); dataSet = dataSetForDesc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().lowest() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().lowest(), sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id, dataSet.emptyDoc1Id ); // Explicit order with missing().highest() dataSet = dataSetForAsc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc().missing().highest() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc().missing().highest(), sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id ); dataSet = dataSetForDesc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().highest() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().highest(), sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id ); @@ -309,42 +329,55 @@ public void missingValue_explicit() { // Explicit order with missing().use( ... ) dataSet = dataSetForAsc; query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ) ); + .missing().use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, fieldType ) ), sortMode, + fieldStructure + ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id ); dataSet = dataSetForAsc; query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL ) ) ); + .missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL, fieldType ) ), sortMode, + fieldStructure + ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.emptyDoc1Id, dataSet.doc2Id, dataSet.doc3Id ); dataSet = dataSetForAsc; query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL ) ) ); + .missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL, fieldType ) ), sortMode, + fieldStructure + ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.emptyDoc1Id, dataSet.doc3Id ); dataSet = dataSetForAsc; query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL ) ) ); + .missing().use( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL, fieldType ) ), sortMode, + fieldStructure + ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3254") - public void missingValue_explicit_multipleEmpty() { - assumeTestParametersWork(); + void missingValue_explicit_multipleEmpty(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( fieldStructure, fieldType, sortMode ); DataSet dataSet = dataSetForAsc; // We're only using ascending order List docRefHits; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); // using before 1 value docRefHits = matchAllQuery( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ) ) + .missing().use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, fieldType ) ), sortMode, + fieldStructure + ) .fetchAllHits(); assertThatHits( docRefHits ).ordinals( 0, 1, 2, 3 ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.emptyDoc2Id, @@ -355,7 +388,9 @@ public void missingValue_explicit_multipleEmpty() { // using between 1 and 2 value docRefHits = matchAllQuery( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL ) ) ) + .missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL, fieldType ) ), sortMode, + fieldStructure + ) .fetchAllHits(); assertThatHits( docRefHits ).ordinal( 0 ).isDocRefHit( index.typeName(), dataSet.doc1Id ); assertThatHits( docRefHits ).ordinals( 1, 2, 3, 4 ) @@ -366,7 +401,9 @@ public void missingValue_explicit_multipleEmpty() { // using between 2 and 3 value docRefHits = matchAllQuery( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL ) ) ) + .missing().use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL, fieldType ) ), sortMode, + fieldStructure + ) .fetchAllHits(); assertThatHits( docRefHits ).ordinal( 0 ).isDocRefHit( index.typeName(), dataSet.doc1Id ); assertThatHits( docRefHits ).ordinal( 1 ).isDocRefHit( index.typeName(), dataSet.doc2Id ); @@ -377,7 +414,9 @@ public void missingValue_explicit_multipleEmpty() { // using after 3 value docRefHits = matchAllQuery( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL ) ) ).fetchAllHits(); + .missing().use( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL, fieldType ) ), sortMode, + fieldStructure + ).fetchAllHits(); assertThatHits( docRefHits ).ordinal( 0 ).isDocRefHit( index.typeName(), dataSet.doc1Id ); assertThatHits( docRefHits ).ordinal( 1 ).isDocRefHit( index.typeName(), dataSet.doc2Id ); assertThatHits( docRefHits ).ordinal( 2 ).isDocRefHit( index.typeName(), dataSet.doc3Id ); @@ -386,22 +425,25 @@ public void missingValue_explicit_multipleEmpty() { dataSet.emptyDoc3Id, dataSet.emptyDoc4Id ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3254") - public void missingValue_multipleEmpty_useExistingDocumentValue() { - assumeTestParametersWork(); + void missingValue_multipleEmpty_useExistingDocumentValue(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( fieldStructure, fieldType, sortMode ); DataSet dataSet = dataSetForAsc; // We're only using ascending order List docRefHits; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); - Object docValue1 = getSingleValueForMissingUse( DOCUMENT_1_ORDINAL ); - Object docValue2 = getSingleValueForMissingUse( DOCUMENT_2_ORDINAL ); - Object docValue3 = getSingleValueForMissingUse( DOCUMENT_3_ORDINAL ); + Object docValue1 = getSingleValueForMissingUse( DOCUMENT_1_ORDINAL, fieldType ); + Object docValue2 = getSingleValueForMissingUse( DOCUMENT_2_ORDINAL, fieldType ); + Object docValue3 = getSingleValueForMissingUse( DOCUMENT_3_ORDINAL, fieldType ); // using doc 1 value docRefHits = matchAllQuery( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( docValue1 ) ) + .missing().use( docValue1 ), sortMode, fieldStructure ) .fetchAllHits(); assertThatHits( docRefHits ).ordinals( 0, 1, 2, 3, 4 ) .hasDocRefHitsAnyOrder( index.typeName(), dataSet.doc1Id, dataSet.emptyDoc1Id, @@ -411,7 +453,7 @@ public void missingValue_multipleEmpty_useExistingDocumentValue() { // using doc 2 value docRefHits = matchAllQuery( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( docValue2 ) ) + .missing().use( docValue2 ), sortMode, fieldStructure ) .fetchAllHits(); assertThatHits( docRefHits ).ordinal( 0 ).isDocRefHit( index.typeName(), dataSet.doc1Id ); assertThatHits( docRefHits ).ordinals( 1, 2, 3, 4, 5 ) @@ -421,7 +463,7 @@ public void missingValue_multipleEmpty_useExistingDocumentValue() { // using doc 3 value docRefHits = matchAllQuery( dataSet, f -> f.field( fieldPath ).asc() - .missing().use( docValue3 ) ) + .missing().use( docValue3 ), sortMode, fieldStructure ) .fetchAllHits(); assertThatHits( docRefHits ).ordinal( 0 ).isDocRefHit( index.typeName(), dataSet.doc1Id ); assertThatHits( docRefHits ).ordinal( 1 ).isDocRefHit( index.typeName(), dataSet.doc2Id ); @@ -430,15 +472,20 @@ public void missingValue_multipleEmpty_useExistingDocumentValue() { dataSet.emptyDoc2Id, dataSet.emptyDoc3Id, dataSet.emptyDoc4Id ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4162") - public void factoryWithRoot() { - assumeTestParametersWork(); + void factoryWithRoot(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( fieldStructure, fieldType, sortMode ); AbstractObjectBinding parentObjectBinding = index.binding().getParentObject( fieldStructure ); - assumeTrue( "This test is only relevant when the field is located on an object field", - parentObjectBinding.absolutePath != null ); + assumeTrue( + parentObjectBinding.absolutePath != null, + "This test is only relevant when the field is located on an object field" + ); DataSet dataSet = dataSetForAsc; assertThatQuery( index.query() @@ -449,7 +496,7 @@ public void factoryWithRoot() { .sort( ( (Function>) f -> f.withRoot( parentObjectBinding.absolutePath ) .field( parentObjectBinding.getRelativeFieldName( fieldStructure, fieldType ) ) ) - .andThen( this::applySortMode ) + .andThen( (FieldSortOptionsStep optionsStep1) -> applySortMode( optionsStep1, sortMode ) ) // Don't call this.applyFilter: we need to use the relative name of the discriminator field. .andThen( optionsStep -> { if ( fieldStructure.isInNested() ) { @@ -464,17 +511,20 @@ public void factoryWithRoot() { .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id ); } - @Test + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") @TestForIssue(jiraKey = { "HSEARCH-4513" }) - public void concurrentQueriesUsingSameSort() { - assumeTestParametersWork(); + void concurrentQueriesUsingSameSort(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( fieldStructure, fieldType, sortMode ); DataSet dataSet; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); StubMappingScope scope = index.createScope(); - SearchSort sort = applyFilter( applySortMode( scope.sort().field( fieldPath ) ) ).toSort(); + SearchSort sort = applyFilter( applySortMode( scope.sort().field( fieldPath ), sortMode ), fieldStructure ).toSort(); dataSet = dataSetForAsc; SearchQuery query1 = scope.query() @@ -495,24 +545,31 @@ public void concurrentQueriesUsingSameSort() { .hasNoHits(); } - @Test - public void missingValue_multipleOptionsSameTime() { - assumeTestParametersWork(); + @ParameterizedTest(name = "{0} - {2} - {1}") + @MethodSource("params") + @TestForIssue(jiraKey = { "HSEARCH-4513" }) + void missingValue_multipleOptionsSameTime(TestedFieldStructure fieldStructure, + FieldTypeDescriptor fieldType, SortMode sortMode, + DataSet dataSetForAsc, DataSet dataSetForDesc) { + assumeTestParametersWork( fieldStructure, fieldType, sortMode ); DataSet dataSet; SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldStructure, fieldType ); // Explicit order with missing().last() dataSet = dataSetForAsc; query = matchNonEmptyAndEmpty1Query( dataSet, - f -> f.field( fieldPath ).asc().missing().last().missing().lowest().missing().first() ); + f -> f.field( fieldPath ).asc().missing().last().missing().lowest().missing().first(), sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id ); dataSet = dataSetForDesc; - query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().first().missing().highest() ); + query = matchNonEmptyAndEmpty1Query( dataSet, f -> f.field( fieldPath ).desc().missing().first().missing().highest(), + sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.emptyDoc1Id, dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id ); @@ -521,7 +578,8 @@ public void missingValue_multipleOptionsSameTime() { .missing().first() .missing().highest() .missing().last() - .missing().lowest() + .missing().lowest(), sortMode, + fieldStructure ); assertThatQuery( query ) .hasDocRefHitsExactOrder( index.typeName(), dataSet.doc3Id, dataSet.doc2Id, dataSet.doc1Id, @@ -529,12 +587,14 @@ public void missingValue_multipleOptionsSameTime() { } private SearchQuery matchNonEmptyQuery(DataSet dataSet, - Function> sortContributor) { - return matchNonEmptyQuery( dataSet, sortContributor, index.createScope() ); + Function> sortContributor, + SortMode sortMode, TestedFieldStructure fieldStructure) { + return matchNonEmptyQuery( dataSet, sortContributor, index.createScope(), sortMode, fieldStructure ); } private SearchQuery matchNonEmptyQuery(DataSet dataSet, - Function> sortContributor, StubMappingScope scope) { + Function> sortContributor, StubMappingScope scope, + SortMode sortMode, TestedFieldStructure fieldStructure) { return query( dataSet, f -> f.matchAll() @@ -542,48 +602,57 @@ private SearchQuery matchNonEmptyQuery(DataSet dataSet, .matchingAny( Arrays.asList( dataSet.emptyDoc1Id, dataSet.emptyDoc2Id, dataSet.emptyDoc3Id, dataSet.emptyDoc4Id ) ) ), sortContributor, - scope + scope, + sortMode, + fieldStructure ); } private SearchQuery matchNonEmptyAndEmpty1Query(DataSet dataSet, - Function> sortContributor) { - return matchNonEmptyAndEmpty1Query( dataSet, sortContributor, index.createScope() ); + Function> sortContributor, + SortMode sortMode, TestedFieldStructure fieldStructure) { + return matchNonEmptyAndEmpty1Query( dataSet, sortContributor, index.createScope(), sortMode, fieldStructure ); } private SearchQuery matchNonEmptyAndEmpty1Query(DataSet dataSet, - Function> sortContributor, StubMappingScope scope) { + Function> sortContributor, StubMappingScope scope, + SortMode sortMode, TestedFieldStructure fieldStructure) { return query( dataSet, f -> f.matchAll().except( f.id().matchingAny( Arrays.asList( dataSet.emptyDoc2Id, dataSet.emptyDoc3Id, dataSet.emptyDoc4Id ) ) ), sortContributor, - scope + scope, + sortMode, + fieldStructure ); } private SearchQuery matchAllQuery(DataSet dataSet, - Function> sortContributor) { - return matchAllQuery( dataSet, sortContributor, index.createScope() ); + Function> sortContributor, + SortMode sortMode, TestedFieldStructure fieldStructure) { + return matchAllQuery( dataSet, sortContributor, index.createScope(), sortMode, fieldStructure ); } private SearchQuery matchAllQuery(DataSet dataSet, - Function> sortContributor, StubMappingScope scope) { - return query( dataSet, f -> f.matchAll(), sortContributor, scope ); + Function> sortContributor, StubMappingScope scope, + SortMode sortMode, TestedFieldStructure fieldStructure) { + return query( dataSet, f -> f.matchAll(), sortContributor, scope, sortMode, fieldStructure ); } private SearchQuery query(DataSet dataSet, Function predicateContributor, Function> sortContributor, - StubMappingScope scope) { + StubMappingScope scope, SortMode sortMode, TestedFieldStructure fieldStructure) { return scope.query() .where( predicateContributor ) .routing( dataSet.routingKey ) - .sort( sortContributor.andThen( this::applySortMode ).andThen( this::applyFilter ) ) + .sort( sortContributor.andThen( t -> applySortMode( t, sortMode ) ) + .andThen( t -> applyFilter( t, fieldStructure ) ) ) .toQuery(); } - private FieldSortOptionsStep applySortMode(FieldSortOptionsStep optionsStep) { + private FieldSortOptionsStep applySortMode(FieldSortOptionsStep optionsStep, SortMode sortMode) { if ( sortMode != null ) { return optionsStep.mode( sortMode ); } @@ -592,7 +661,8 @@ private SearchQuery query(DataSet dataSet, } } - private FieldSortOptionsStep applyFilter(FieldSortOptionsStep optionsStep) { + private FieldSortOptionsStep applyFilter(FieldSortOptionsStep optionsStep, + TestedFieldStructure fieldStructure) { if ( fieldStructure.isInNested() ) { return optionsStep.filter( f -> f.match() .field( index.binding().getDiscriminatorFieldPath( fieldStructure ) ) @@ -603,35 +673,38 @@ private SearchQuery query(DataSet dataSet, } } - private void assumeTestParametersWork() { + private void assumeTestParametersWork(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType, + SortMode sortMode) { assumeFalse( - "This combination is not expected to work", - isMedianWithNestedField() || isSumOrAvgOrMedianWithStringField() || isSumWithTemporalField() + isMedianWithNestedField( sortMode, fieldStructure ) + || isSumOrAvgOrMedianWithStringField( sortMode, fieldType ) + || isSumWithTemporalField( sortMode, fieldType ), + "This combination is not expected to work" ); } - private boolean isSumOrAvgOrMedianWithStringField() { + private boolean isSumOrAvgOrMedianWithStringField(SortMode sortMode, FieldTypeDescriptor fieldType) { return EnumSet.of( SortMode.SUM, SortMode.AVG, SortMode.MEDIAN ).contains( sortMode ) && String.class.equals( fieldType.getJavaType() ); } - private boolean isSumWithTemporalField() { + private boolean isSumWithTemporalField(SortMode sortMode, FieldTypeDescriptor fieldType) { return SortMode.SUM.equals( sortMode ) && ( Temporal.class.isAssignableFrom( fieldType.getJavaType() ) || MonthDay.class.equals( fieldType.getJavaType() ) ); } - private boolean isMedianWithNestedField() { + private boolean isMedianWithNestedField(SortMode sortMode, TestedFieldStructure fieldStructure) { return SortMode.MEDIAN.equals( sortMode ) && fieldStructure.isInNested(); } - private String getFieldPath() { + private String getFieldPath(TestedFieldStructure fieldStructure, FieldTypeDescriptor fieldType) { return index.binding().getFieldPath( fieldStructure, fieldType ); } @SuppressWarnings("unchecked") - private F getSingleValueForMissingUse(int ordinal) { + private F getSingleValueForMissingUse(int ordinal, FieldTypeDescriptor fieldType) { F value = fieldType.getAscendingUniqueTermValues().getSingle().get( ordinal ); if ( fieldType instanceof NormalizedStringFieldTypeDescriptor diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortDynamicFieldIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortDynamicFieldIT.java index 33aefc5d236..f0f7976bfa1 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortDynamicFieldIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortDynamicFieldIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.backend.tck.search.sort; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.List; @@ -22,34 +22,34 @@ import org.hibernate.search.engine.search.sort.dsl.SortFinalStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class FieldSortDynamicFieldIT { +class FieldSortDynamicFieldIT { - private static List> supportedFieldTypes; + private static final List> supportedFieldTypes = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - supportedFieldTypes = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { for ( FieldTypeDescriptor fieldType : FieldTypeDescriptor.getAll() ) { if ( fieldType.isFieldSortSupported() ) { supportedFieldTypes.add( fieldType ); - parameters.add( new Object[] { fieldType } ); + parameters.add( Arguments.of( fieldType ) ); } } - return parameters.toArray( new Object[0][] ); + } + + public static List params() { + return parameters; } private static final String DOCUMENT_1 = "1"; @@ -62,14 +62,14 @@ public static Object[][] parameters() { private static final int DOCUMENT_2_ORDINAL = 3; private static final int DOCUMENT_3_ORDINAL = 5; - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( mainIndex ) .setup(); @@ -77,15 +77,10 @@ public static void setup() { initData(); } - private final FieldTypeDescriptor fieldTypeDescriptor; - - public FieldSortDynamicFieldIT(FieldTypeDescriptor fieldTypeDescriptor) { - this.fieldTypeDescriptor = fieldTypeDescriptor; - } - - @Test - public void simple() { - String fieldPath = mainFieldPath(); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void simple(FieldTypeDescriptor fieldTypeDescriptor) { + String fieldPath = mainFieldPath( fieldTypeDescriptor ); assertThatQuery( matchNonEmptyQuery( f -> f.field( fieldPath ).asc() ) ) .hasDocRefHitsExactOrder( mainIndex.typeName(), DOCUMENT_1, DOCUMENT_2, DOCUMENT_3 ); @@ -93,18 +88,19 @@ public void simple() { .hasDocRefHitsExactOrder( mainIndex.typeName(), DOCUMENT_3, DOCUMENT_2, DOCUMENT_1 ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4531") - public void neverPopulated() { + void neverPopulated(FieldTypeDescriptor fieldTypeDescriptor) { assumeTrue( - "This backend doesn't support sorts on a field of type '" + fieldTypeDescriptor - + "' that is missing from some of the target indexes.", TckConfiguration.get().getBackendFeatures() - .supportsFieldSortWhenFieldMissingInSomeTargetIndexes( fieldTypeDescriptor.getJavaType() ) + .supportsFieldSortWhenFieldMissingInSomeTargetIndexes( fieldTypeDescriptor.getJavaType() ), + "This backend doesn't support sorts on a field of type '" + fieldTypeDescriptor + + "' that is missing from some of the target indexes." ); - String neverPopulatedFieldPath = neverPopulatedFieldPath(); - String mainFieldPath = mainFieldPath(); + String neverPopulatedFieldPath = neverPopulatedFieldPath( fieldTypeDescriptor ); + String mainFieldPath = mainFieldPath( fieldTypeDescriptor ); // The field that wasn't populated shouldn't have any effect on the sort, // but it shouldn't trigger an exception, either (see HSEARCH-4531). @@ -131,15 +127,11 @@ private SearchQuery matchNonEmptyQuery( .toQuery(); } - private String mainFieldPath() { - return mainFieldPath( fieldTypeDescriptor ); - } - private static String mainFieldPath(FieldTypeDescriptor type) { return IndexBinding.fieldPath( type, "main" ); } - private String neverPopulatedFieldPath() { + private String neverPopulatedFieldPath(FieldTypeDescriptor fieldTypeDescriptor) { return IndexBinding.fieldPath( fieldTypeDescriptor, "neverPopulated" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortFilteringSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortFilteringSpecificsIT.java index bb612a56ff4..ce5d3272a2a 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortFilteringSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortFilteringSpecificsIT.java @@ -24,57 +24,50 @@ import org.hibernate.search.engine.search.sort.dsl.SortFinalStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests behavior related to * {@link org.hibernate.search.engine.search.sort.dsl.SortFilterStep#filter(Function) filtering} * that is not tested in {@link FieldSortBaseIT}. */ -@RunWith(Parameterized.class) -public class FieldSortFilteringSpecificsIT { +class FieldSortFilteringSpecificsIT { private static Stream> supportedTypeDescriptors() { return FieldTypeDescriptor.getAll().stream() .filter( typeDescriptor -> typeDescriptor.isFieldSortSupported() ); } - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - List parameters = new ArrayList<>(); + public static List params() { + List parameters = new ArrayList<>(); supportedTypeDescriptors().forEach( fieldTypeDescriptor -> { - parameters.add( new Object[] { fieldTypeDescriptor } ); + parameters.add( Arguments.of( fieldTypeDescriptor ) ); } ); - return parameters.toArray( new Object[0][] ); + return parameters; } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldTypeDescriptor; - - public FieldSortFilteringSpecificsIT(FieldTypeDescriptor fieldTypeDescriptor) { - this.fieldTypeDescriptor = fieldTypeDescriptor; - } - - @Test - public void nonNested() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void nonNested(FieldTypeDescriptor fieldTypeDescriptor) { String fieldPath = index.binding().flattenedObject.relativeFieldName + "." + index.binding().flattenedObject.fieldModels.get( fieldTypeDescriptor ).relativeFieldName; @@ -89,8 +82,9 @@ public void nonNested() { ); } - @Test - public void invalidNestedPath_parent() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidNestedPath_parent(FieldTypeDescriptor fieldTypeDescriptor) { String fieldPath = index.binding().nestedObject1.relativeFieldName + "." + index.binding().nestedObject1.fieldModels.get( fieldTypeDescriptor ).relativeFieldName; String fieldInParentPath = index.binding().fieldModels.get( fieldTypeDescriptor ).relativeFieldName; @@ -106,8 +100,9 @@ public void invalidNestedPath_parent() { + " are allowed here." ); } - @Test - public void invalidNestedPath_sibling() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidNestedPath_sibling(FieldTypeDescriptor fieldTypeDescriptor) { String fieldPath = index.binding().nestedObject1.relativeFieldName + "." + index.binding().nestedObject1.fieldModels.get( fieldTypeDescriptor ).relativeFieldName; String fieldInSiblingPath = index.binding().nestedObject2.relativeFieldName + "." diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortScaledSpecificsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortScaledSpecificsIT.java index be4d4694463..e50aaf1bf30 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortScaledSpecificsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortScaledSpecificsIT.java @@ -14,33 +14,33 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.engine.reporting.spi.EventContexts; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class FieldSortScaledSpecificsIT { +class FieldSortScaledSpecificsIT { - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, 2 ) ).name( "main" ); private static final SimpleMappedIndex incompatibleDecimalScaleIndex = SimpleMappedIndex.of( root -> new IndexBinding( root, 5 ) ).name( "incompatibleDecimalScale" ); - @Before - public void initData() { + @BeforeEach + void initData() { setupHelper.start().withIndexes( mainIndex, incompatibleDecimalScaleIndex ).setup(); } @Test - public void incompatibleDecimalScale() { + void incompatibleDecimalScale() { StubMappingScope scope = mainIndex.createScope( incompatibleDecimalScaleIndex ); String fieldPath = "scaledBigDecimal"; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortTypeCheckingAndConversionIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortTypeCheckingAndConversionIT.java index 461016aa5cb..3cf467e3c3b 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortTypeCheckingAndConversionIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortTypeCheckingAndConversionIT.java @@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.List; @@ -39,7 +39,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.ValueWrapper; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer; @@ -47,32 +47,32 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests behavior related to type checking and type conversion of DSL arguments * for sorts by field value. */ -@RunWith(Parameterized.class) -public class FieldSortTypeCheckingAndConversionIT { +class FieldSortTypeCheckingAndConversionIT { - private static List> supportedFieldTypes; + private static final List> supportedFieldTypes = new ArrayList<>(); + private static final List parameters = new ArrayList<>(); - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - supportedFieldTypes = new ArrayList<>(); - List parameters = new ArrayList<>(); + static { for ( FieldTypeDescriptor fieldType : FieldTypeDescriptor.getAll() ) { if ( fieldType.isFieldSortSupported() ) { supportedFieldTypes.add( fieldType ); - parameters.add( new Object[] { fieldType } ); + parameters.add( Arguments.of( fieldType ) ); } } - return parameters.toArray( new Object[0][] ); + } + + public static List params() { + return parameters; } private static final String DOCUMENT_1 = "1"; @@ -93,8 +93,8 @@ public static Object[][] parameters() { private static final int DOCUMENT_3_ORDINAL = 5; private static final int AFTER_DOCUMENT_3_ORDINAL = 6; - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -107,8 +107,8 @@ public static Object[][] parameters() { private static final SimpleMappedIndex incompatibleIndex = SimpleMappedIndex.of( IncompatibleIndexBinding::new ).name( "incompatible" ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start() .withIndexes( mainIndex, compatibleIndex, rawFieldCompatibleIndex, missingFieldIndex, incompatibleIndex ) .setup(); @@ -116,62 +116,63 @@ public static void setup() { initData(); } - private final FieldTypeDescriptor fieldTypeDescriptor; - - public FieldSortTypeCheckingAndConversionIT(FieldTypeDescriptor fieldTypeDescriptor) { - this.fieldTypeDescriptor = fieldTypeDescriptor; - } - - @Test - public void withDslConverters_dslConverterEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withDslConverters_dslConverterEnabled(FieldTypeDescriptor fieldTypeDescriptor) { SearchQuery query; - String fieldPath = getFieldWithDslConverterPath(); + String fieldPath = getFieldWithDslConverterPath( fieldTypeDescriptor ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( new ValueWrapper<>( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ) ) ); + .use( new ValueWrapper<>( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, fieldTypeDescriptor ) ) ) ); assertThatQuery( query ) .hasDocRefHitsExactOrder( mainIndex.typeName(), EMPTY, DOCUMENT_1, DOCUMENT_2, DOCUMENT_3 ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( new ValueWrapper<>( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL ) ) ) ); + .use( new ValueWrapper<>( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL, + fieldTypeDescriptor + ) ) ) ); assertThatQuery( query ) .hasDocRefHitsExactOrder( mainIndex.typeName(), DOCUMENT_1, EMPTY, DOCUMENT_2, DOCUMENT_3 ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( new ValueWrapper<>( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL ) ) ) ); + .use( new ValueWrapper<>( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL, + fieldTypeDescriptor + ) ) ) ); assertThatQuery( query ) .hasDocRefHitsExactOrder( mainIndex.typeName(), DOCUMENT_1, DOCUMENT_2, EMPTY, DOCUMENT_3 ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( new ValueWrapper<>( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL ) ) ) ); + .use( new ValueWrapper<>( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL, fieldTypeDescriptor ) ) ) ); assertThatQuery( query ) .hasDocRefHitsExactOrder( mainIndex.typeName(), DOCUMENT_1, DOCUMENT_2, DOCUMENT_3, EMPTY ); } - @Test - public void withDslConverters_dslConverterDisabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withDslConverters_dslConverterDisabled(FieldTypeDescriptor fieldTypeDescriptor) { SearchQuery query; - String fieldPath = getFieldWithDslConverterPath(); + String fieldPath = getFieldWithDslConverterPath( fieldTypeDescriptor ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ), ValueConvert.NO ) ); + .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, fieldTypeDescriptor ), ValueConvert.NO ) ); assertThatQuery( query ) .hasDocRefHitsExactOrder( mainIndex.typeName(), EMPTY, DOCUMENT_1, DOCUMENT_2, DOCUMENT_3 ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL ), ValueConvert.NO ) ); + .use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_1_AND_2_ORDINAL, fieldTypeDescriptor ), ValueConvert.NO ) ); assertThatQuery( query ) .hasDocRefHitsExactOrder( mainIndex.typeName(), DOCUMENT_1, EMPTY, DOCUMENT_2, DOCUMENT_3 ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL ), ValueConvert.NO ) ); + .use( getSingleValueForMissingUse( BETWEEN_DOCUMENT_2_AND_3_ORDINAL, fieldTypeDescriptor ), ValueConvert.NO ) ); assertThatQuery( query ) .hasDocRefHitsExactOrder( mainIndex.typeName(), DOCUMENT_1, DOCUMENT_2, EMPTY, DOCUMENT_3 ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL ), ValueConvert.NO ) ); + .use( getSingleValueForMissingUse( AFTER_DOCUMENT_3_ORDINAL, fieldTypeDescriptor ), ValueConvert.NO ) ); assertThatQuery( query ) .hasDocRefHitsExactOrder( mainIndex.typeName(), DOCUMENT_1, DOCUMENT_2, DOCUMENT_3, EMPTY ); } - @Test - public void unsortable() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void unsortable(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = mainIndex.createScope(); - String fieldPath = getNonSortableFieldPath(); + String fieldPath = getNonSortableFieldPath( fieldTypeDescriptor ); assertThatThrownBy( () -> { scope.sort().field( fieldPath ); @@ -183,11 +184,12 @@ public void unsortable() { ); } - @Test - public void invalidType_noDslConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidType_noDslConverter(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = mainIndex.createScope(); - String absoluteFieldPath = getFieldPath(); + String absoluteFieldPath = getFieldPath( fieldTypeDescriptor ); Object invalidValueToMatch = new InvalidType(); assertThatThrownBy( @@ -204,11 +206,12 @@ public void invalidType_noDslConverter() { ) ); } - @Test - public void invalidType_withDslConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void invalidType_withDslConverter(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = mainIndex.createScope(); - String absoluteFieldPath = getFieldWithDslConverterPath(); + String absoluteFieldPath = getFieldWithDslConverterPath( fieldTypeDescriptor ); Object invalidValueToMatch = new InvalidType(); assertThatThrownBy( @@ -225,15 +228,16 @@ public void invalidType_withDslConverter() { ) ); } - @Test - public void multiIndex_withCompatibleIndex_usingField() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withCompatibleIndex_usingField(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = mainIndex.createScope( compatibleIndex ); SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldTypeDescriptor ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ), scope ); + .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, fieldTypeDescriptor ) ), scope ); /* * Not testing the ordering of results here because some documents have the same value. @@ -249,16 +253,19 @@ public void multiIndex_withCompatibleIndex_usingField() { } ); } - @Test - public void multiIndex_withRawFieldCompatibleIndex_dslConverterEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withRawFieldCompatibleIndex_dslConverterEnabled(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = mainIndex.createScope( rawFieldCompatibleIndex ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldTypeDescriptor ); assertThatThrownBy( () -> { matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( new ValueWrapper<>( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ) ), scope ); + .use( new ValueWrapper<>( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, + fieldTypeDescriptor + ) ) ), scope ); } ) .isInstanceOf( SearchException.class ) @@ -271,15 +278,16 @@ public void multiIndex_withRawFieldCompatibleIndex_dslConverterEnabled() { ) ); } - @Test - public void multiIndex_withRawFieldCompatibleIndex_dslConverterDisabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withRawFieldCompatibleIndex_dslConverterDisabled(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = mainIndex.createScope( rawFieldCompatibleIndex ); SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldTypeDescriptor ); query = matchAllQuery( f -> f.field( fieldPath ).asc().missing() - .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ), ValueConvert.NO ), scope ); + .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, fieldTypeDescriptor ), ValueConvert.NO ), scope ); /* * Not testing the ordering of results here because some documents have the same value. @@ -295,23 +303,24 @@ public void multiIndex_withRawFieldCompatibleIndex_dslConverterDisabled() { } ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex_dslConverterEnabled() { + void multiIndex_withMissingFieldIndex_dslConverterEnabled(FieldTypeDescriptor fieldTypeDescriptor) { assumeTrue( - "This backend doesn't support sorts on a field of type '" + fieldTypeDescriptor - + "' that is missing from some of the target indexes.", TckConfiguration.get().getBackendFeatures() - .supportsFieldSortWhenFieldMissingInSomeTargetIndexes( fieldTypeDescriptor.getJavaType() ) + .supportsFieldSortWhenFieldMissingInSomeTargetIndexes( fieldTypeDescriptor.getJavaType() ), + "This backend doesn't support sorts on a field of type '" + fieldTypeDescriptor + + "' that is missing from some of the target indexes." ); StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldTypeDescriptor ); query = matchNonEmptyQuery( f -> f.field( fieldPath ).asc().missing() - .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ), scope ); + .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, fieldTypeDescriptor ) ), scope ); /* * Not testing the ordering of results here because it's not what we are interested in: @@ -327,23 +336,24 @@ public void multiIndex_withMissingFieldIndex_dslConverterEnabled() { } ); } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex_dslConverterDisabled() { + void multiIndex_withMissingFieldIndex_dslConverterDisabled(FieldTypeDescriptor fieldTypeDescriptor) { assumeTrue( - "This backend doesn't support sorts on a field of type '" + fieldTypeDescriptor - + "' that is missing from some of the target indexes.", TckConfiguration.get().getBackendFeatures() - .supportsFieldSortWhenFieldMissingInSomeTargetIndexes( fieldTypeDescriptor.getJavaType() ) + .supportsFieldSortWhenFieldMissingInSomeTargetIndexes( fieldTypeDescriptor.getJavaType() ), + "This backend doesn't support sorts on a field of type '" + fieldTypeDescriptor + + "' that is missing from some of the target indexes." ); StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); SearchQuery query; - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldTypeDescriptor ); query = matchNonEmptyQuery( f -> f.field( fieldPath ).asc().missing() - .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ), ValueConvert.NO ), scope ); + .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, fieldTypeDescriptor ), ValueConvert.NO ), scope ); /* * Not testing the ordering of results here because it's not what we are interested in: @@ -363,23 +373,24 @@ public void multiIndex_withMissingFieldIndex_dslConverterDisabled() { * Test the behavior when even the parent field of the field to sort on is missing, * and that parent field is nested in the main index. */ - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4173") - public void multiIndex_withMissingFieldIndex_nested() { + void multiIndex_withMissingFieldIndex_nested(FieldTypeDescriptor fieldTypeDescriptor) { assumeTrue( - "This backend doesn't support sorts on a field of type '" + fieldTypeDescriptor - + "' that is missing from some of the target indexes.", TckConfiguration.get().getBackendFeatures() - .supportsFieldSortWhenFieldMissingInSomeTargetIndexes( fieldTypeDescriptor.getJavaType() ) + .supportsFieldSortWhenFieldMissingInSomeTargetIndexes( fieldTypeDescriptor.getJavaType() ), + "This backend doesn't support sorts on a field of type '" + fieldTypeDescriptor + + "' that is missing from some of the target indexes." ); StubMappingScope scope = mainIndex.createScope( missingFieldIndex ); SearchQuery query; - String fieldPath = getFieldInNestedPath(); + String fieldPath = getFieldInNestedPath( fieldTypeDescriptor ); query = matchNonEmptyQuery( f -> f.field( fieldPath ).asc().missing() - .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL ) ), scope ); + .use( getSingleValueForMissingUse( BEFORE_DOCUMENT_1_ORDINAL, fieldTypeDescriptor ) ), scope ); /* * Not testing the ordering of results here because it's not what we are interested in: @@ -395,11 +406,12 @@ public void multiIndex_withMissingFieldIndex_nested() { } ); } - @Test - public void multiIndex_withIncompatibleIndex_dslConverterEnabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex_dslConverterEnabled(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = mainIndex.createScope( incompatibleIndex ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldTypeDescriptor ); assertThatThrownBy( () -> { @@ -416,11 +428,12 @@ public void multiIndex_withIncompatibleIndex_dslConverterEnabled() { ) ); } - @Test - public void multiIndex_withIncompatibleIndex_dslConverterDisabled() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void multiIndex_withIncompatibleIndex_dslConverterDisabled(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = mainIndex.createScope( incompatibleIndex ); - String fieldPath = getFieldPath(); + String fieldPath = getFieldPath( fieldTypeDescriptor ); assertThatThrownBy( () -> { @@ -458,20 +471,20 @@ private SearchQuery matchNonEmptyQuery( .toQuery(); } - private String getFieldPath() { + private String getFieldPath(FieldTypeDescriptor fieldTypeDescriptor) { return mainIndex.binding().fieldModels.get( fieldTypeDescriptor ).relativeFieldName; } - private String getFieldInNestedPath() { + private String getFieldInNestedPath(FieldTypeDescriptor fieldTypeDescriptor) { return mainIndex.binding().nested.relativeFieldName + '.' + mainIndex.binding().nested.fieldModels.get( fieldTypeDescriptor ).relativeFieldName; } - private String getFieldWithDslConverterPath() { + private String getFieldWithDslConverterPath(FieldTypeDescriptor fieldTypeDescriptor) { return mainIndex.binding().fieldWithDslConverterModels.get( fieldTypeDescriptor ).relativeFieldName; } - private String getNonSortableFieldPath() { + private String getNonSortableFieldPath(FieldTypeDescriptor fieldTypeDescriptor) { return mainIndex.binding().nonSortableFieldModels.get( fieldTypeDescriptor ).relativeFieldName; } @@ -485,7 +498,7 @@ private static void initDocument(IndexBinding indexBinding, DocumentElement docu } @SuppressWarnings("unchecked") - private F getSingleValueForMissingUse(int ordinal) { + private F getSingleValueForMissingUse(int ordinal, FieldTypeDescriptor fieldTypeDescriptor) { F value = fieldTypeDescriptor.getAscendingUniqueTermValues().getSingle().get( ordinal ); if ( fieldTypeDescriptor instanceof NormalizedStringFieldTypeDescriptor diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortTypeIndependentIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortTypeIndependentIT.java index a1205b1c82a..b08e1e17ed2 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortTypeIndependentIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortTypeIndependentIT.java @@ -12,14 +12,14 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests related to behavior independent from the field type @@ -28,20 +28,20 @@ * Behavior that is specific to the field type is tested elsewhere, * e.g. {@link FieldSortBaseIT} and {@link FieldSortUnsupportedTypesIT}. */ -public class FieldSortTypeIndependentIT { +class FieldSortTypeIndependentIT { - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void unknownField() { + void unknownField() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = "unknownField"; @@ -60,7 +60,7 @@ public void unknownField() { } @Test - public void objectField_nested() { + void objectField_nested() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().nestedObject.relativeFieldName; @@ -75,7 +75,7 @@ public void objectField_nested() { } @Test - public void objectField_flattened() { + void objectField_flattened() { StubMappingScope scope = index.createScope(); String absoluteFieldPath = index.binding().flattenedObject.relativeFieldName; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortUnsupportedTypesIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortUnsupportedTypesIT.java index 241abf29c14..7b00c6ca2fe 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortUnsupportedTypesIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/FieldSortUnsupportedTypesIT.java @@ -17,61 +17,54 @@ import org.hibernate.search.engine.reporting.spi.EventContexts; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModelsByType; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests basic behavior of field sort common to all unsupported types, * i.e. error messages. */ -@RunWith(Parameterized.class) -public class FieldSortUnsupportedTypesIT { +class FieldSortUnsupportedTypesIT { private static Stream> unsupportedTypeDescriptors() { return FieldTypeDescriptor.getAll().stream() .filter( typeDescriptor -> !typeDescriptor.isFieldSortSupported() ); } - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - List parameters = new ArrayList<>(); + public static List params() { + List parameters = new ArrayList<>(); unsupportedTypeDescriptors().forEach( fieldTypeDescriptor -> { - parameters.add( new Object[] { fieldTypeDescriptor } ); + parameters.add( Arguments.of( fieldTypeDescriptor ) ); } ); - return parameters.toArray( new Object[0][] ); + return parameters; } - @ClassRule - public static SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public static SearchSetupHelper setupHelper = SearchSetupHelper.createGlobal(); private static final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @BeforeClass - public static void setup() { + @BeforeAll + static void setup() { setupHelper.start().withIndex( index ).setup(); } - private final FieldTypeDescriptor fieldTypeDescriptor; - - public FieldSortUnsupportedTypesIT(FieldTypeDescriptor fieldTypeDescriptor) { - this.fieldTypeDescriptor = fieldTypeDescriptor; - } - - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3798") - public void error_notSupported() { + void error_notSupported(FieldTypeDescriptor fieldTypeDescriptor) { StubMappingScope scope = index.createScope(); - String absoluteFieldPath = getFieldPath(); + String absoluteFieldPath = getFieldPath( fieldTypeDescriptor ); assertThatThrownBy( () -> scope.sort().field( absoluteFieldPath ) @@ -86,7 +79,7 @@ public void error_notSupported() { ) ); } - private String getFieldPath() { + private String getFieldPath(FieldTypeDescriptor fieldTypeDescriptor) { return index.binding().fieldModels.get( fieldTypeDescriptor ).relativeFieldName; } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/SearchSortIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/SearchSortIT.java index c9f5bde2f1a..1396ddbd201 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/SearchSortIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/sort/SearchSortIT.java @@ -33,21 +33,21 @@ import org.hibernate.search.engine.search.sort.dsl.SearchSortFactoryExtension; import org.hibernate.search.engine.search.sort.dsl.SortFinalStep; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Generic tests for sorts. More specific tests can be found in other classes, * such as {@link FieldSortBaseIT} or {@link DistanceSortBaseIT}. */ -public class SearchSortIT { +class SearchSortIT { private static final int INDEX_ORDER_CHECKS = 10; @@ -56,8 +56,8 @@ public class SearchSortIT { private static final String THIRD_ID = "3"; private static final String EMPTY_ID = "empty"; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex mainIndex = SimpleMappedIndex.of( IndexBinding::new ).name( "main" ); @@ -66,8 +66,8 @@ public class SearchSortIT { // What matters here is that is a different index. SimpleMappedIndex.of( IndexBinding::new ).name( "other" ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndexes( mainIndex, otherIndex ).setup(); initData(); @@ -83,7 +83,7 @@ private SearchQuery simpleQuery( } @Test - public void byIndexOrder() { + void byIndexOrder() { /* * We don't really know in advance what the index order is, but we want it to be consistent. * Thus we just test that the order stays the same over several calls. @@ -103,7 +103,7 @@ public void byIndexOrder() { } @Test - public void byDefault_score() { + void byDefault_score() { StubMappingScope scope = mainIndex.createScope(); assertThatQuery( scope.query() @@ -118,7 +118,7 @@ public void byDefault_score() { } @Test - public void byScore() { + void byScore() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query; @@ -148,7 +148,7 @@ public void byScore() { } @Test - public void separateSort() { + void separateSort() { StubMappingScope scope = mainIndex.createScope(); SearchQuery query; @@ -176,7 +176,7 @@ public void separateSort() { } @Test - public void reuseSortInstance_onScopeTargetingSameIndexes() { + void reuseSortInstance_onScopeTargetingSameIndexes() { StubMappingScope scope = mainIndex.createScope(); SearchSort sort = scope .sort().field( "string" ).asc().missing().last().toSort(); @@ -219,7 +219,7 @@ public void reuseSortInstance_onScopeTargetingSameIndexes() { } @Test - public void reuseSortInstance_onScopeTargetingDifferentIndexes() { + void reuseSortInstance_onScopeTargetingDifferentIndexes() { StubMappingScope scope = mainIndex.createScope(); SearchSort sort = scope .sort().field( "string" ).asc().missing().last().toSort(); @@ -249,7 +249,7 @@ public void reuseSortInstance_onScopeTargetingDifferentIndexes() { } @Test - public void extension() { + void extension() { SearchQuery query; // Mandatory extension, supported @@ -367,21 +367,21 @@ public void extension() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath() { + void toAbsolutePath() { assertThat( mainIndex.createScope().sort().toAbsolutePath( "string" ) ) .isEqualTo( "string" ); } @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_withRoot() { + void toAbsolutePath_withRoot() { assertThat( mainIndex.createScope().sort().withRoot( "flattened" ).toAbsolutePath( "string" ) ) .isEqualTo( "flattened.string" ); } @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_null() { + void toAbsolutePath_null() { assertThatThrownBy( () -> mainIndex.createScope().sort().toAbsolutePath( null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContaining( "'relativeFieldPath' must not be null" ); @@ -389,7 +389,7 @@ public void toAbsolutePath_null() { @Test @TestForIssue(jiraKey = "HSEARCH-4162") - public void toAbsolutePath_withRoot_null() { + void toAbsolutePath_withRoot_null() { assertThatThrownBy( () -> mainIndex.createScope().sort().withRoot( "flattened" ).toAbsolutePath( null ) ) .isInstanceOf( IllegalArgumentException.class ) .hasMessageContaining( "'relativeFieldPath' must not be null" ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/DistanceProjectionComplexCasesIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/DistanceProjectionComplexCasesIT.java index d05a719b237..344dff2d328 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/DistanceProjectionComplexCasesIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/DistanceProjectionComplexCasesIT.java @@ -14,26 +14,25 @@ import org.hibernate.search.engine.spatial.DistanceUnit; import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.integrationtest.backend.tck.search.predicate.AbstractSpatialWithinPredicateIT; -import org.hibernate.search.integrationtest.backend.tck.search.projection.DistanceProjectionSingleValuedBaseIT; import org.hibernate.search.util.impl.integrationtest.common.assertion.TestComparators; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.assertj.core.api.ListAssert; -public class DistanceProjectionComplexCasesIT extends AbstractSpatialWithinPredicateIT { +class DistanceProjectionComplexCasesIT extends AbstractSpatialWithinPredicateIT { private static final Comparator APPROX_M_COMPARATOR = TestComparators.approximateDouble( 10.0 ); private static final Comparator APPROX_KM_COMPARATOR = TestComparators.approximateDouble( 0.010 ); /** - * See also {@link DistanceProjectionSingleValuedBaseIT#several()}. + * See also {@code org.hibernate.search.integrationtest.backend.tck.search.projection.DistanceProjectionSingleValuedBaseIT#several()}. *

* The main difference is that we're targeting multiple fields here. */ @Test - public void several() { + void several() { StubMappingScope scope = mainIndex.createScope(); ListAssert> hitsAssert = assertThatQuery( scope.query() @@ -75,12 +74,12 @@ public void several() { } /** - * See also {@link DistanceProjectionSingleValuedBaseIT#sortable_withSort()}. + * See also {@code org.hibernate.search.integrationtest.backend.tck.search.projection.DistanceProjectionSingleValuedBaseIT#sortable_withSort()}. *

* The main difference is that we're composing multiple sorts here. */ @Test - public void withDistanceSort() { + void withDistanceSort() { StubMappingScope scope = mainIndex.createScope(); GeoPoint center = GeoPoint.of( 45.749828, 4.854172 ); @@ -108,7 +107,7 @@ public void withDistanceSort() { * This is relevant for Elasticsearch, which generates a name for computed values based on the field name. */ @Test - public void longFieldName() { + void longFieldName() { StubMappingScope scope = mainIndex.createScope(); assertThatQuery( scope.query() diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/DistanceSearchableSortableIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/DistanceSearchableSortableIT.java index b005529c721..aca0aa87a98 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/DistanceSearchableSortableIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/DistanceSearchableSortableIT.java @@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; -import static org.junit.Assume.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import org.hibernate.search.engine.backend.common.DocumentReference; import org.hibernate.search.engine.backend.document.IndexFieldReference; @@ -19,16 +19,16 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.spatial.GeoPoint; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DistanceSearchableSortableIT { +class DistanceSearchableSortableIT { private static final String OURSON_QUI_BOIT_ID = "ourson qui boit"; private static final GeoPoint OURSON_QUI_BOIT_GEO_POINT = GeoPoint.of( 45.7705687, 4.835233 ); @@ -41,19 +41,19 @@ public class DistanceSearchableSortableIT { private static final GeoPoint METRO_GARIBALDI = GeoPoint.of( 45.7515926, 4.8514779 ); - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void searchableSortable() { + void searchableSortable() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() .where( f -> f.spatial().within().field( "searchableSortable" ).circle( METRO_GARIBALDI, 1_500 ) ) @@ -64,10 +64,10 @@ public void searchableSortable() { } @Test - public void searchableNotSortable() { + void searchableNotSortable() { assumeFalse( - "Skipping test for ES GeoPoint as those would become sortable by default in this case.", - TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault() + TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault(), + "Skipping test for ES GeoPoint as those would become sortable by default in this case." ); StubMappingScope scope = index.createScope(); String fieldPath = "searchableNotSortable"; @@ -92,7 +92,7 @@ public void searchableNotSortable() { } @Test - public void searchableNotSortableNotProjectable() { + void searchableNotSortableNotProjectable() { StubMappingScope scope = index.createScope(); String fieldPath = "searchableNotSortableNotProjectable"; @@ -116,10 +116,10 @@ public void searchableNotSortableNotProjectable() { } @Test - public void searchableDefaultSortable() { + void searchableDefaultSortable() { assumeFalse( - "Skipping test for ES GeoPoint as those would become sortable by default in this case.", - TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault() + TckConfiguration.get().getBackendFeatures().fieldsProjectableByDefault(), + "Skipping test for ES GeoPoint as those would become sortable by default in this case." ); StubMappingScope scope = index.createScope(); String fieldPath = "searchableDefaultSortable"; @@ -144,7 +144,7 @@ public void searchableDefaultSortable() { } @Test - public void notSearchableSortable() { + void notSearchableSortable() { StubMappingScope scope = index.createScope(); String fieldPath = "notSearchableSortable"; @@ -168,7 +168,7 @@ public void notSearchableSortable() { } @Test - public void defaultSearchableSortable() { + void defaultSearchableSortable() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() .where( f -> f.spatial().within().field( "defaultSearchableSortable" ).circle( METRO_GARIBALDI, 1_500 ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/MultivaluedSpatialIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/MultivaluedSpatialIT.java index ab74f2f5cfa..55f6ac47c97 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/MultivaluedSpatialIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/spatial/MultivaluedSpatialIT.java @@ -14,17 +14,17 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.spatial.GeoBoundingBox; import org.hibernate.search.engine.spatial.GeoPoint; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-2859") -public class MultivaluedSpatialIT { +class MultivaluedSpatialIT { // latitude increases from south to north // longitude increases from west to east @@ -36,19 +36,19 @@ public class MultivaluedSpatialIT { private static final GeoBoundingBox AROUND_NORTH_WEST_BOX = GeoBoundingBox.of( GeoPoint.of( 8.0, 2.0 ), GeoPoint.of( 6.0, 4.0 ) ); - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); initData(); } @Test - public void boundingBox() { + void boundingBox() { StubMappingScope scope = index.createScope(); SearchQuery query = scope.query() .where( f -> f.spatial().within().field( "geoPoint" ).boundingBox( AROUND_NORTH_WEST_BOX ) ) diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/AbstractShardingRoutingKeyIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/AbstractShardingRoutingKeyIT.java index bdaa2ff8eca..f66c92a00c9 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/AbstractShardingRoutingKeyIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/AbstractShardingRoutingKeyIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.backend.tck.sharding; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.Arrays; @@ -25,20 +25,20 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.impl.CollectionHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * An abstract base for sharding tests with explicit routing keys. */ public abstract class AbstractShardingRoutingKeyIT extends AbstractShardingIT { - @Rule + @RegisterExtension public final SearchSetupHelper setupHelper; private final Set routingKeys; @@ -50,14 +50,14 @@ public abstract class AbstractShardingRoutingKeyIT extends AbstractShardingIT { public AbstractShardingRoutingKeyIT(Function> setupStrategyFunction, Set routingKeys) { super( RoutingMode.EXPLICIT_ROUTING_KEYS ); - this.setupHelper = new SearchSetupHelper( setupStrategyFunction ); + this.setupHelper = SearchSetupHelper.create( setupStrategyFunction ); this.routingKeys = routingKeys; documentCountPerRoutingKey = 100; totalDocumentCount = routingKeys.size() * documentCountPerRoutingKey; } - @Before - public void setup() { + @BeforeEach + void setup() { SearchSetupHelper.SetupContext setupContext = setupHelper.start(); configure( setupContext ); setupContext.withIndex( index ).setup(); @@ -79,7 +79,7 @@ public void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-3314") - public void search() { + void search() { // No routing key => all documents should be returned assertThatQuery( index.createScope().query() .where( f -> f.matchAll() ) @@ -136,7 +136,7 @@ public void search() { @Test @TestForIssue(jiraKey = "HSEARCH-3824") - public void purge_noRoutingKey() { + void purge_noRoutingKey() { assumePurgeSupported(); index.createWorkspace() @@ -150,7 +150,7 @@ public void purge_noRoutingKey() { @Test @TestForIssue(jiraKey = "HSEARCH-3824") - public void purge_oneRoutingKey() { + void purge_oneRoutingKey() { assumePurgeSupported(); Iterator iterator = docIdByRoutingKey.keySet().iterator(); @@ -175,7 +175,7 @@ public void purge_oneRoutingKey() { @Test @TestForIssue(jiraKey = "HSEARCH-3824") - public void purge_twoRoutingKeys() { + void purge_twoRoutingKeys() { assumePurgeSupported(); Iterator iterator = docIdByRoutingKey.keySet().iterator(); @@ -198,7 +198,7 @@ public void purge_twoRoutingKeys() { @Test @TestForIssue(jiraKey = "HSEARCH-3824") - public void purge_allRoutingKeys() { + void purge_allRoutingKeys() { assumePurgeSupported(); index.createWorkspace().purge( routingKeys, OperationSubmitter.blocking(), UnsupportedOperationBehavior.FAIL ) @@ -211,8 +211,8 @@ public void purge_allRoutingKeys() { private void assumePurgeSupported() { assumeTrue( - "This test only makes sense if the backend supports explicit purge", - TckConfiguration.get().getBackendFeatures().supportsExplicitPurge() + TckConfiguration.get().getBackendFeatures().supportsExplicitPurge(), + "This test only makes sense if the backend supports explicit purge" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingDisabledRoutingKeyIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingDisabledRoutingKeyIT.java index 9118d428629..eae594fa17d 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingDisabledRoutingKeyIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingDisabledRoutingKeyIT.java @@ -11,7 +11,7 @@ /** * A basic test for disabled sharding with explicit routing keys. */ -public class ShardingDisabledRoutingKeyIT extends AbstractShardingRoutingKeyIT { +class ShardingDisabledRoutingKeyIT extends AbstractShardingRoutingKeyIT { public ShardingDisabledRoutingKeyIT() { // Use more than one routing key diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingHashDocumentIdIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingHashDocumentIdIT.java index 6eb271e9bf9..c8f282a4cca 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingHashDocumentIdIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingHashDocumentIdIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.backend.tck.sharding; import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.Arrays; @@ -20,27 +20,27 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.UnsupportedOperationBehavior; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * A basic test for hash-based sharding with document IDs (without routing keys). */ @PortedFromSearch5(original = "org.hibernate.search.test.shards.ShardsTest") -public class ShardingHashDocumentIdIT extends AbstractShardingIT { +class ShardingHashDocumentIdIT extends AbstractShardingIT { private static final int SHARD_COUNT = 3; // Create more document than shards, so that multiple documents end up in the same shard, like in real life private static final int ESTIMATED_DOCUMENT_COUNT_PER_SHARD = 100; private static final int TOTAL_DOCUMENT_COUNT = SHARD_COUNT * ESTIMATED_DOCUMENT_COUNT_PER_SHARD; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper( + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create( tckBackendHelper -> tckBackendHelper.createHashBasedShardingBackendSetupStrategy( SHARD_COUNT ) ); @@ -51,8 +51,8 @@ public ShardingHashDocumentIdIT() { super( RoutingMode.DOCUMENT_IDS ); } - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); // Do not provide explicit routing keys when indexing; the backend should fall back to using IDs @@ -69,7 +69,7 @@ public void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-3314") - public void search() { + void search() { // No routing key => all documents should be returned assertThatQuery( index.createScope().query() .where( f -> f.matchAll() ) @@ -104,7 +104,7 @@ public void search() { @Test @TestForIssue(jiraKey = "HSEARCH-3824") - public void purgeWithRoutingKey() { + void purgeWithRoutingKey() { assumePurgeSupported(); Iterator iterator = docIds.iterator(); @@ -124,8 +124,8 @@ public void purgeWithRoutingKey() { private void assumePurgeSupported() { assumeTrue( - "This test only makes sense if the backend supports explicit purge", - TckConfiguration.get().getBackendFeatures().supportsExplicitPurge() + TckConfiguration.get().getBackendFeatures().supportsExplicitPurge(), + "This test only makes sense if the backend supports explicit purge" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingHashRoutingKeyIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingHashRoutingKeyIT.java index 697e94ee195..b6d17e2f8d6 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingHashRoutingKeyIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/sharding/ShardingHashRoutingKeyIT.java @@ -12,7 +12,7 @@ * A basic test for hash-based sharding with explicit routing keys. */ @PortedFromSearch5(original = "org.hibernate.search.test.shards.ShardsTest") -public class ShardingHashRoutingKeyIT extends AbstractShardingRoutingKeyIT { +class ShardingHashRoutingKeyIT extends AbstractShardingRoutingKeyIT { private static final int SHARD_COUNT = 3; diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TckBackendSetupStrategy.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TckBackendSetupStrategy.java index d69d700df21..0e355f4b83e 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TckBackendSetupStrategy.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TckBackendSetupStrategy.java @@ -10,11 +10,11 @@ import java.util.Map; import java.util.Optional; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; -import org.junit.rules.TestRule; +import org.junit.jupiter.api.extension.Extension; public abstract class TckBackendSetupStrategy { @@ -28,8 +28,8 @@ public TckBackendSetupStrategy(C backendConfiguration) { properties.putAll( backendConfiguration.rawBackendProperties() ); } - public final Optional testRule() { - return useConfigurationTestRule ? backendConfiguration.testRule() : Optional.empty(); + public final Optional extension() { + return useConfigurationTestRule ? backendConfiguration.extension() : Optional.empty(); } public Map createBackendConfigurationProperties(TestConfigurationProvider configurationProvider) { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TestedFieldStructure.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TestedFieldStructure.java index b00ad448a84..748a924a2eb 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TestedFieldStructure.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/TestedFieldStructure.java @@ -11,8 +11,6 @@ import java.util.List; import java.util.Objects; -import org.hibernate.search.integrationtest.backend.tck.search.sort.FieldSortBaseIT; - /** * Represents the structure of a tested field: located at the root or in a nested document, * single-valued or multi-valued, ... @@ -25,7 +23,7 @@ * You need set up your test to create one field per structure, * and then query the "fieldStructure" object in your test instance to target a different field * based on that. - * See for example {@link FieldSortBaseIT}. + * See for example {@code org.hibernate.search.integrationtest.backend.tck.search.sort.FieldSortBaseIT}. */ public class TestedFieldStructure { diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/rule/SearchSetupHelper.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/extension/SearchSetupHelper.java similarity index 68% rename from integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/rule/SearchSetupHelper.java rename to integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/extension/SearchSetupHelper.java index a87fc13e7a4..1afd6debace 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/rule/SearchSetupHelper.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/testsupport/util/extension/SearchSetupHelper.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or . */ -package org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule; +package org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension; import java.io.IOException; import java.lang.invoke.MethodHandles; @@ -37,6 +37,7 @@ import org.hibernate.search.util.common.logging.impl.LoggerFactory; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; import org.hibernate.search.util.impl.integrationtest.common.bean.ForbiddenBeanProvider; +import org.hibernate.search.util.impl.integrationtest.common.extension.ComposedExtension; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapping; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingImpl; @@ -44,35 +45,93 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingKey; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingSchemaManagementStrategy; -import org.junit.rules.RuleChain; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -public class SearchSetupHelper implements TestRule { +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.AfterTestExecutionCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.BeforeTestExecutionCallback; +import org.junit.jupiter.api.extension.Extension; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestExecutionExceptionHandler; + +public class SearchSetupHelper + implements AfterAllCallback, AfterEachCallback, AfterTestExecutionCallback, + BeforeAllCallback, BeforeEachCallback, BeforeTestExecutionCallback, TestExecutionExceptionHandler { + + private enum Type { + CLASS, + METHOD; + } private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() ); private final TestConfigurationProvider configurationProvider; - private final TckBackendSetupStrategy setupStrategy; - private final TestRule delegateRule; + private final Type type; + private TckBackendSetupStrategy setupStrategy; + private ComposedExtension delegate; private final List environments = new ArrayList<>(); private final List integrationPartialBuildStates = new ArrayList<>(); private final List mappings = new ArrayList<>(); private TckBackendAccessor backendAccessor; - public SearchSetupHelper() { - this( TckBackendHelper::createDefaultBackendSetupStrategy ); + public static SearchSetupHelper create() { + return new SearchSetupHelper( Type.METHOD, TckBackendHelper::createDefaultBackendSetupStrategy ); + } + + public static SearchSetupHelper createGlobal() { + return new SearchSetupHelper( Type.CLASS, TckBackendHelper::createDefaultBackendSetupStrategy ); + } + + public static SearchSetupHelper create(Function> setupStrategyFunction) { + return new SearchSetupHelper( Type.METHOD, setupStrategyFunction ); + } + + public static SearchSetupHelper createGlobal(Function> setupStrategyFunction) { + return new SearchSetupHelper( Type.CLASS, setupStrategyFunction ); } - public SearchSetupHelper(Function> setupStrategyFunction) { + public SearchSetupHelper(Type type, Function> setupStrategyFunction) { this.configurationProvider = new TestConfigurationProvider(); + this.type = type; + init( setupStrategyFunction ); + } + + private void init(Function> setupStrategyFunction) { this.setupStrategy = setupStrategyFunction.apply( TckConfiguration.get().getBackendHelper() ); - Optional setupStrategyTestRule = setupStrategy.testRule(); - this.delegateRule = setupStrategyTestRule - .map( rule -> RuleChain.outerRule( configurationProvider ).around( rule ) ) - .orElse( configurationProvider ); + Optional setupStrategyTestExtension = setupStrategy.extension(); + + ComposedExtension.FullExtension ownActions = new ComposedExtension.FullExtension.Builder() + .withAfterAll( afterAllContext -> { + if ( Type.CLASS.equals( type ) ) { + cleanUp(); + } + } ).withAfterEach( afterEachContext -> { + if ( Type.METHOD.equals( type ) ) { + cleanUp(); + } + } ).withTestExecutionExceptionHandler( (testExecutionExceptionContext, throwable) -> { + // When used as a "ClassExtension", exceptions are not properly reported by JUnit. + // Log them so that we have something in the logs, at least. + log.warn( + "Exception thrown by test and caught by SearchSetupHelper rule: " + throwable.getMessage(), + throwable + ); + throw throwable; + } ).build(); + + this.delegate = new ComposedExtension( + ownActions, + setupStrategyTestExtension + .map( extension -> new ComposedExtension( extension, configurationProvider ) ) + .orElse( configurationProvider ) + ); + } + + public SearchSetupHelper with(Function> setupStrategyFunction) { + init( setupStrategyFunction ); + return this; } public SetupContext start() { @@ -105,32 +164,42 @@ public TckBackendAccessor getBackendAccessor() { } @Override - public Statement apply(Statement base, Description description) { - return statement( base, description ); + public void afterAll(ExtensionContext context) throws Exception { + if ( !runningInNestedContext( context ) ) { + delegate.afterAll( context ); + } } - private Statement statement(final Statement base, final Description description) { - Statement wrapped = new Statement() { - @Override - public void evaluate() throws Throwable { - // Using the closer like this allows to suppress exceptions thrown by the 'finally' block. - try ( Closer closer = new Closer<>() ) { - try { - base.evaluate(); - } - catch (RuntimeException e) { - // When used as a @ClassRule, exceptions are not properly reported by JUnit. - // Log them so that we have something in the logs, at least. - log.warn( "Exception thrown by test and caught by SearchSetupHelper rule: " + e.getMessage(), e ); - throw e; - } - finally { - cleanUp( closer ); - } - } - } - }; - return delegateRule.apply( wrapped, description ); + @Override + public void afterEach(ExtensionContext context) throws Exception { + delegate.afterEach( context ); + } + + @Override + public void afterTestExecution(ExtensionContext context) throws Exception { + delegate.afterTestExecution( context ); + } + + @Override + public void beforeAll(ExtensionContext context) throws Exception { + if ( !runningInNestedContext( context ) ) { + delegate.beforeAll( context ); + } + } + + @Override + public void beforeEach(ExtensionContext context) throws Exception { + delegate.beforeEach( context ); + } + + @Override + public void beforeTestExecution(ExtensionContext context) throws Exception { + delegate.beforeTestExecution( context ); + } + + @Override + public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable { + delegate.handleTestExecutionException( context, throwable ); } public void cleanUp() throws IOException { @@ -170,8 +239,8 @@ public class SetupContext { SetupContext(String defaultBackendName, AllAwareConfigurationPropertySource basePropertySource) { this.unusedPropertyChecker = ConfigurationPropertyChecker.create(); this.propertySource = unusedPropertyChecker.wrap( basePropertySource ) - .withOverride( - unusedPropertyChecker.wrap( AllAwareConfigurationPropertySource.fromMap( overriddenProperties ) ) ); + .withOverride( unusedPropertyChecker.wrap( + AllAwareConfigurationPropertySource.fromMap( overriddenProperties ) ) ); } public SetupContext expectCustomBeans() { @@ -206,7 +275,8 @@ public SetupContext withIndexProperty(String indexName, String keyRadical, Objec public SetupContext withIndexProperty(String backendName, String indexName, String keyRadical, Object value) { return withBackendProperty( backendName, - BackendSettings.INDEXES + "." + indexName + "." + keyRadical, value ); + BackendSettings.INDEXES + "." + indexName + "." + keyRadical, value + ); } public SetupContext withIndexes(StubMappedIndex... mappedIndexes) { @@ -293,4 +363,11 @@ default StubMapping doSecondPhase() { StubMapping doSecondPhase(ConfigurationPropertySource overrides); } + + private static boolean runningInNestedContext(ExtensionContext context) { + // if we are running @Nested tests all of the Before/After are executed for each nested test + // as well as for the nested class itself, leading to BeforeAll/AfterAll extensions being called more than needed. + return context.getRequiredTestClass().isMemberClass(); + } + } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/AbstractIndexWorkspaceSimpleOperationIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/AbstractIndexWorkspaceSimpleOperationIT.java index 59f1688afc0..7f10f997381 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/AbstractIndexWorkspaceSimpleOperationIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/AbstractIndexWorkspaceSimpleOperationIT.java @@ -17,14 +17,14 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.work.execution.spi.IndexWorkspace; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendAccessor; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.logging.impl.Log; import org.hibernate.search.util.common.logging.impl.LoggerFactory; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.awaitility.Awaitility; @@ -34,13 +34,13 @@ public abstract class AbstractIndexWorkspaceSimpleOperationIT { private static final Integer DOCUMENT_COUNT = 50; - @Rule + @RegisterExtension public final SearchSetupHelper setupHelper; private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); protected AbstractIndexWorkspaceSimpleOperationIT() { - this( new SearchSetupHelper() ); + this( SearchSetupHelper.create() ); } protected AbstractIndexWorkspaceSimpleOperationIT(SearchSetupHelper setupHelper) { @@ -48,7 +48,7 @@ protected AbstractIndexWorkspaceSimpleOperationIT(SearchSetupHelper setupHelper) } @Test - public void success() { + void success() { setup(); IndexWorkspace workspace = index.createWorkspace(); @@ -64,7 +64,7 @@ public void success() { } @Test - public void failure() { + void failure() { setup(); IndexWorkspace workspace = index.createWorkspace(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexerIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexerIT.java index 77c94bc90d8..852ca414151 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexerIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexerIT.java @@ -24,31 +24,29 @@ import org.hibernate.search.engine.backend.work.execution.OperationSubmitter; import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexer; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.logging.impl.Log; import org.hibernate.search.util.common.logging.impl.LoggerFactory; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.awaitility.Awaitility; /** * Verify that the {@link IndexIndexer}, provided by a backend, is working properly, storing correctly the indexes. */ -@RunWith(Parameterized.class) -public class IndexIndexerIT { +class IndexIndexerIT { - @Parameterized.Parameters(name = "commit: {0}, refresh: {1}") - public static List parameters() { - List params = new ArrayList<>(); + public static List params() { + List params = new ArrayList<>(); for ( DocumentCommitStrategy commitStrategy : DocumentCommitStrategy.values() ) { for ( DocumentRefreshStrategy refreshStrategy : DocumentRefreshStrategy.values() ) { - params.add( new Object[] { commitStrategy, refreshStrategy } ); + params.add( Arguments.of( commitStrategy, refreshStrategy ) ); } } return params; @@ -58,27 +56,19 @@ public static List parameters() { private static final int NUMBER_OF_BOOKS = 200; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - private final DocumentCommitStrategy commitStrategy; - private final DocumentRefreshStrategy refreshStrategy; - - public IndexIndexerIT(DocumentCommitStrategy commitStrategy, - DocumentRefreshStrategy refreshStrategy) { - this.commitStrategy = commitStrategy; - this.refreshStrategy = refreshStrategy; - } - - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); } - @Test - public void success() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}") + @MethodSource("params") + void success(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { IndexIndexer indexer = index.createIndexer(); CompletableFuture[] tasks = new CompletableFuture[NUMBER_OF_BOOKS]; @@ -99,7 +89,7 @@ public void success() { assertThatFuture( future ).isSuccessful(); int expectedMatchingBooks1 = NUMBER_OF_BOOKS; - searchAfterIndexChanges( () -> assertThatQuery( index.query() + searchAfterIndexChanges( refreshStrategy, () -> assertThatQuery( index.query() .where( f -> f.match().field( "title" ).matching( "lord" ) ) ) .hasTotalHitCount( expectedMatchingBooks1 ) ); @@ -122,7 +112,7 @@ public void success() { assertThatFuture( future ).isSuccessful(); int expectedMatchingBooks2 = expectedMatchingBooks1 - booksToUpdate; - searchAfterIndexChanges( () -> assertThatQuery( index.query() + searchAfterIndexChanges( refreshStrategy, () -> assertThatQuery( index.query() .where( f -> f.match().field( "title" ).matching( "lord" ) ) ) .hasTotalHitCount( expectedMatchingBooks2 ) ); @@ -144,13 +134,14 @@ public void success() { assertThatFuture( future ).isSuccessful(); int expectedMatchingBooks3 = expectedMatchingBooks2 - booksToDelete; - searchAfterIndexChanges( () -> assertThatQuery( index.query() + searchAfterIndexChanges( refreshStrategy, () -> assertThatQuery( index.query() .where( f -> f.match().field( "title" ).matching( "lord" ) ) ) .hasTotalHitCount( expectedMatchingBooks3 ) ); } - @Test - public void add_failure() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}") + @MethodSource("params") + void add_failure(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { IndexIndexer indexer = index.createIndexer(); // Trigger failures in the next operations @@ -175,8 +166,9 @@ public void add_failure() { } } - @Test - public void addOrUpdate_failure() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}") + @MethodSource("params") + void addOrUpdate_failure(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { IndexIndexer indexer = index.createIndexer(); // Trigger failures in the next operations @@ -201,8 +193,9 @@ public void addOrUpdate_failure() { } } - @Test - public void delete_failure() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}") + @MethodSource("params") + void delete_failure(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy) { IndexIndexer indexer = index.createIndexer(); // Trigger failures in the next operations @@ -225,7 +218,7 @@ public void delete_failure() { } } - private void searchAfterIndexChanges(Runnable assertion) { + private void searchAfterIndexChanges(DocumentRefreshStrategy refreshStrategy, Runnable assertion) { if ( DocumentRefreshStrategy.FORCE.equals( refreshStrategy ) ) { // Refresh was supposedly already handled assertion.run(); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexerLargeDocumentsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexerLargeDocumentsIT.java index d40c19b0b0f..b1041fc682b 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexerLargeDocumentsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexerLargeDocumentsIT.java @@ -26,14 +26,14 @@ import org.hibernate.search.engine.backend.work.execution.spi.UnsupportedOperationBehavior; import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.test.annotation.TestForIssue; import org.hibernate.search.util.impl.test.data.TextContent; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.awaitility.Awaitility; @@ -45,7 +45,7 @@ * and AWS request signing is sensitive to the content length. */ @TestForIssue(jiraKey = "HSEARCH-4239") -public class IndexIndexerLargeDocumentsIT { +class IndexIndexerLargeDocumentsIT { // This must be high, otherwise the bug won't be reproduced. private static final int MANY_LARGE_DOCUMENTS_COUNT = 2000; @@ -60,8 +60,8 @@ public class IndexIndexerLargeDocumentsIT { } } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); @@ -74,28 +74,28 @@ public IndexIndexerLargeDocumentsIT() { : DocumentRefreshStrategy.FORCE; } - @Before - public void setup() { + @BeforeEach + void setup() { setupHelper.start().withIndex( index ).setup(); } @Test - public void manyLargeDocuments_add() { + void manyLargeDocuments_add() { doTest( MANY_LARGE_DOCUMENTS_COUNT, this::largeValue, Operation.ADD ); } @Test - public void manyLargeDocuments_addOrUpdate() { + void manyLargeDocuments_addOrUpdate() { doTest( MANY_LARGE_DOCUMENTS_COUNT, this::largeValue, Operation.ADD_OR_UPDATE ); } @Test - public void oneVeryLargeDocuments_add() { + void oneVeryLargeDocuments_add() { doTest( 1, this::veryLargeValue, Operation.ADD ); } @Test - public void oneVeryLargeDocuments_addOrUpdate() { + void oneVeryLargeDocuments_addOrUpdate() { doTest( 1, this::veryLargeValue, Operation.ADD_OR_UPDATE ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexingPlanIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexingPlanIT.java index 4824af5c17f..841236b6e58 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexingPlanIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexIndexingPlanIT.java @@ -14,6 +14,8 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; +import java.util.Arrays; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.Function; @@ -26,7 +28,7 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.configuration.DefaultAnalysisDefinitions; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendSetupStrategy; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.logging.impl.Log; import org.hibernate.search.util.common.logging.impl.LoggerFactory; @@ -36,60 +38,46 @@ import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubSession; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.awaitility.Awaitility; -@RunWith(Parameterized.class) -public class IndexIndexingPlanIT { +class IndexIndexingPlanIT { private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() ); private static final String MULTI_TENANCY_LABEL = "Multi-tenancy enabled explicitly"; public static final String NO_MULTI_TENANCY_LABEL = "No multi-tenancy"; - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - return new Object[][] { - { + public static List params() { + return Arrays.asList( + Arguments.of( NO_MULTI_TENANCY_LABEL, (Function>) TckBackendHelper::createDefaultBackendSetupStrategy, null - }, - { + ), + Arguments.of( MULTI_TENANCY_LABEL, (Function>) TckBackendHelper::createMultiTenancyBackendSetupStrategy, "tenant_1" - } - }; + ) + ); } - @Rule - public final SearchSetupHelper setupHelper; - - private final String tenantId; - private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - private final String label; - + @RegisterExtension + public SearchSetupHelper setupHelper = SearchSetupHelper.create(); private StubSession sessionContext; - public IndexIndexingPlanIT(String label, Function> setupStrategyFunction, + public void init(String label, Function> setupStrategyFunction, String tenantId) { - this.setupHelper = new SearchSetupHelper( setupStrategyFunction ); - this.tenantId = tenantId; - this.label = label; - } - - @Before - public void setup() { + setupHelper.with( setupStrategyFunction ); SearchSetupHelper.SetupContext setupContext = setupHelper.start().withIndex( index ); if ( MULTI_TENANCY_LABEL.equals( label ) ) { setupContext.withMultiTenancy(); @@ -100,8 +88,11 @@ public void setup() { sessionContext = mapping.session( tenantId ); } - @Test - public void success() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void success(String label, Function> setupStrategyFunction, + String tenantId) { + init( label, setupStrategyFunction, tenantId ); IndexIndexingPlan plan = index.createIndexingPlan( sessionContext ); // Add @@ -147,8 +138,11 @@ public void success() { .hasDocRefHitsAnyOrder( index.typeName(), "3" ); } - @Test - public void discard() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void discard(String label, Function> setupStrategyFunction, + String tenantId) { + init( label, setupStrategyFunction, tenantId ); IndexIndexingPlan plan = index.createIndexingPlan( sessionContext ); plan.add( referenceProvider( "1" ), document -> document.addValue( index.binding().title, "Title of Book 1" ) ); @@ -166,8 +160,11 @@ public void discard() { .hasDocRefHitsAnyOrder( index.typeName(), "2" ); } - @Test - public void add_failure() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void add_failure(String label, Function> setupStrategyFunction, + String tenantId) { + init( label, setupStrategyFunction, tenantId ); IndexIndexingPlan plan = index.createIndexingPlan( sessionContext ); plan.add( referenceProvider( "1" ), document -> document.addValue( index.binding().title, "Title of Book 1" ) ); plan.add( referenceProvider( "2" ), document -> document.addValue( index.binding().title, "Title of Book 2" ) ); @@ -190,9 +187,11 @@ public void add_failure() { } } - @Test - public void addOrUpdate_failure() { - setup(); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void addOrUpdate_failure(String label, Function> setupStrategyFunction, + String tenantId) { + init( label, setupStrategyFunction, tenantId ); IndexIndexingPlan plan = index.createIndexingPlan( sessionContext ); plan.addOrUpdate( referenceProvider( "1" ), document -> document.addValue( index.binding().title, "Title of Book 1" ) ); @@ -216,9 +215,11 @@ public void addOrUpdate_failure() { } } - @Test - public void delete_failure() { - setup(); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void delete_failure(String label, Function> setupStrategyFunction, + String tenantId) { + init( label, setupStrategyFunction, tenantId ); IndexIndexingPlan plan = index.createIndexingPlan( sessionContext ); plan.delete( referenceProvider( "1" ) ); @@ -242,10 +243,12 @@ public void delete_failure() { } } - @Test + @ParameterizedTest(name = "{0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3852") - public void failure_report() { - setup(); + void failure_report(String label, Function> setupStrategyFunction, + String tenantId) { + init( label, setupStrategyFunction, tenantId ); IndexIndexingPlan plan = index.createIndexingPlan( sessionContext ); plan.add( referenceProvider( "1" ), document -> document.addValue( index.binding().title, "Title of Book 1" ) ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceFlushIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceFlushIT.java index 8371a11208c..a82115c80f6 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceFlushIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceFlushIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.backend.tck.work; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.concurrent.CompletableFuture; @@ -17,14 +17,15 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; -public class IndexWorkspaceFlushIT extends AbstractIndexWorkspaceSimpleOperationIT { - @Before +class IndexWorkspaceFlushIT extends AbstractIndexWorkspaceSimpleOperationIT { + + @BeforeEach public void checkAssumptions() { assumeTrue( - "This test only makes sense if the backend supports explicit flush", - TckConfiguration.get().getBackendFeatures().supportsExplicitFlush() + TckConfiguration.get().getBackendFeatures().supportsExplicitFlush(), + "This test only makes sense if the backend supports explicit flush" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceIT.java index 475fbf1dc82..2ff1fbbf5ff 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceIT.java @@ -8,7 +8,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Collections; @@ -21,13 +21,13 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendHelper; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubSession; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Verify that the work executor operations: @@ -37,35 +37,39 @@ * {@link IndexWorkspace#refresh(OperationSubmitter, UnsupportedOperationBehavior)} * work properly, in every backends. */ -public class IndexWorkspaceIT { +class IndexWorkspaceIT { private static final String TENANT_1 = "tenant1"; private static final String TENANT_2 = "tenant2"; private static final int NUMBER_OF_BOOKS = 200; - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - @Rule - public SearchSetupHelper multiTenancySetupHelper = - new SearchSetupHelper( TckBackendHelper::createMultiTenancyBackendSetupStrategy ); + @RegisterExtension + public final SearchSetupHelper multiTenancySetupHelper = + SearchSetupHelper.create( TckBackendHelper::createMultiTenancyBackendSetupStrategy ); private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); - @Before + @BeforeEach + void initSessionContexts() { + } + + @BeforeEach public void checkAssumptions() { assumeTrue( - "This test only makes sense if the backend supports explicit purge, mergeSegments, flush and refresh", TckConfiguration.get().getBackendFeatures().supportsExplicitPurge() && TckConfiguration.get().getBackendFeatures().supportsExplicitMergeSegments() && TckConfiguration.get().getBackendFeatures().supportsExplicitFlush() - && TckConfiguration.get().getBackendFeatures().supportsExplicitRefresh() + && TckConfiguration.get().getBackendFeatures().supportsExplicitRefresh(), + "This test only makes sense if the backend supports explicit purge, mergeSegments, flush and refresh" ); } @Test - public void runMergeSegmentsPurgeAndFlushAndRefreshInSequence() { + void runMergeSegmentsPurgeAndFlushAndRefreshInSequence() { setupHelper.start().withIndex( index ).setup(); StubSession noTenantSessionContext = index.mapping().session(); @@ -89,7 +93,7 @@ public void runMergeSegmentsPurgeAndFlushAndRefreshInSequence() { } @Test - public void runMergeSegmentsPurgeAndFlushAndRefreshWithMultiTenancy() { + void runMergeSegmentsPurgeAndFlushAndRefreshWithMultiTenancy() { multiTenancySetupHelper.start().withIndex( index ).withMultiTenancy().setup(); StubSession tenant1SessionContext = index.mapping().session( TENANT_1 ); StubSession tenant2SessionContext = index.mapping().session( TENANT_2 ); diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceMergeSegmentsIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceMergeSegmentsIT.java index 092b37d4eca..f35d2ec5693 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceMergeSegmentsIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceMergeSegmentsIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.backend.tck.work; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.concurrent.CompletableFuture; @@ -17,15 +17,15 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; -public class IndexWorkspaceMergeSegmentsIT extends AbstractIndexWorkspaceSimpleOperationIT { +class IndexWorkspaceMergeSegmentsIT extends AbstractIndexWorkspaceSimpleOperationIT { - @Before - public void checkAssumptions() { + @BeforeEach + void checkAssumptions() { assumeTrue( - "This test only makes sense if the backend supports explicit mergeSegments", - TckConfiguration.get().getBackendFeatures().supportsExplicitMergeSegments() + TckConfiguration.get().getBackendFeatures().supportsExplicitMergeSegments(), + "This test only makes sense if the backend supports explicit mergeSegments" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspacePurgeIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspacePurgeIT.java index 1434de0a2bc..fd45756e7d0 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspacePurgeIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspacePurgeIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.backend.tck.work; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Collections; import java.util.concurrent.CompletableFuture; @@ -19,15 +19,15 @@ import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; -public class IndexWorkspacePurgeIT extends AbstractIndexWorkspaceSimpleOperationIT { +class IndexWorkspacePurgeIT extends AbstractIndexWorkspaceSimpleOperationIT { - @Before + @BeforeEach public void checkAssumptions() { assumeTrue( - "This test only makes sense if the backend supports explicit purge", - TckConfiguration.get().getBackendFeatures().supportsExplicitPurge() + TckConfiguration.get().getBackendFeatures().supportsExplicitPurge(), + "This test only makes sense if the backend supports explicit purge" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceRefreshIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceRefreshIT.java index f035e6cdeed..ede0d3947f4 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceRefreshIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexWorkspaceRefreshIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.backend.tck.work; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.concurrent.CompletableFuture; @@ -16,22 +16,22 @@ import org.hibernate.search.engine.backend.work.execution.spi.UnsupportedOperationBehavior; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckBackendAccessor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; -public class IndexWorkspaceRefreshIT extends AbstractIndexWorkspaceSimpleOperationIT { +class IndexWorkspaceRefreshIT extends AbstractIndexWorkspaceSimpleOperationIT { public IndexWorkspaceRefreshIT() { - super( new SearchSetupHelper( helper -> helper.createRarePeriodicRefreshBackendSetupStrategy() ) ); + super( SearchSetupHelper.create( helper -> helper.createRarePeriodicRefreshBackendSetupStrategy() ) ); } - @Before + @BeforeEach public void checkAssumptions() { assumeTrue( - "This test only makes sense if the backend supports explicit refresh", - TckConfiguration.get().getBackendFeatures().supportsExplicitRefresh() + TckConfiguration.get().getBackendFeatures().supportsExplicitRefresh(), + "This test only makes sense if the backend supports explicit refresh" ); } diff --git a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexingFieldTypesIT.java b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexingFieldTypesIT.java index 1d0b8f6c870..86077c2df10 100644 --- a/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexingFieldTypesIT.java +++ b/integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/work/IndexingFieldTypesIT.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement; import org.hibernate.search.engine.backend.types.Projectable; @@ -20,15 +21,14 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor; import org.hibernate.search.integrationtest.backend.tck.testsupport.util.SimpleFieldModel; -import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper; +import org.hibernate.search.integrationtest.backend.tck.testsupport.util.extension.SearchSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex; import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test indexing with various values. @@ -37,35 +37,32 @@ * * @param The type of field values. */ -@RunWith(Parameterized.class) -public class IndexingFieldTypesIT { +class IndexingFieldTypesIT { private static final List> supportedTypeDescriptors = FieldTypeDescriptor.getAll(); - @Parameterized.Parameters(name = "{0}") - public static List> parameters() { - return supportedTypeDescriptors; + public static List params() { + return supportedTypeDescriptors.stream() + .map( Arguments::of ) + .collect( Collectors.toList() ); } - @Rule - public final SearchSetupHelper setupHelper = new SearchSetupHelper(); + @RegisterExtension + public final SearchSetupHelper setupHelper = SearchSetupHelper.create(); - private final SimpleMappedIndex index = SimpleMappedIndex.of( IndexBinding::new ); + private SimpleMappedIndex index; - private final FieldTypeDescriptor typeDescriptor; - - public IndexingFieldTypesIT(FieldTypeDescriptor typeDescriptor) { - this.typeDescriptor = typeDescriptor; - } - - @Before - public void setup() { + public void init(FieldTypeDescriptor typeDescriptor) { + index = SimpleMappedIndex.of( + root -> new IndexBinding( root, typeDescriptor ) ); setupHelper.start().withIndex( index ).setup(); } - @Test - public void withReference() { - List values = new ArrayList<>( this.typeDescriptor.getIndexableValues().getSingle() ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withReference(FieldTypeDescriptor typeDescriptor) { + init( typeDescriptor ); + List values = new ArrayList<>( typeDescriptor.getIndexableValues().getSingle() ); values.add( null ); // Also test null List> expectedDocuments = new ArrayList<>(); @@ -100,9 +97,11 @@ public void withReference() { assertThatQuery( query ).hasHitsAnyOrder( expectedDocuments ); } - @Test - public void withPath() { - List values = new ArrayList<>( this.typeDescriptor.getIndexableValues().getSingle() ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void withPath(FieldTypeDescriptor typeDescriptor) { + init( typeDescriptor ); + List values = new ArrayList<>( typeDescriptor.getIndexableValues().getSingle() ); values.add( null ); // Also test null List> expectedDocuments = new ArrayList<>(); @@ -137,9 +136,11 @@ public void withPath() { assertThatQuery( query ).hasHitsAnyOrder( expectedDocuments ); } - @Test - public void dynamic_withPath() { - List values = new ArrayList<>( this.typeDescriptor.getIndexableValues().getSingle() ); + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dynamic_withPath(FieldTypeDescriptor typeDescriptor) { + init( typeDescriptor ); + List values = new ArrayList<>( typeDescriptor.getIndexableValues().getSingle() ); values.add( null ); // Also test null List> expectedDocuments = new ArrayList<>(); @@ -178,7 +179,7 @@ public void dynamic_withPath() { private class IndexBinding { final SimpleFieldModel fieldModel; - IndexBinding(IndexSchemaElement root) { + IndexBinding(IndexSchemaElement root, FieldTypeDescriptor typeDescriptor) { this.fieldModel = SimpleFieldModel.mapper( typeDescriptor, c -> c.projectable( Projectable.YES ) ) .map( root, "field" ); supportedTypeDescriptors.forEach( fieldType -> { diff --git a/integrationtest/java/modules/orm-coordination-outbox-polling-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/service/orm/elasticsearch/coordination/outboxpolling/JavaModulePathIT.java b/integrationtest/java/modules/orm-coordination-outbox-polling-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/service/orm/elasticsearch/coordination/outboxpolling/JavaModulePathIT.java index a0184cf8da9..50f0f7a4385 100644 --- a/integrationtest/java/modules/orm-coordination-outbox-polling-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/service/orm/elasticsearch/coordination/outboxpolling/JavaModulePathIT.java +++ b/integrationtest/java/modules/orm-coordination-outbox-polling-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/service/orm/elasticsearch/coordination/outboxpolling/JavaModulePathIT.java @@ -6,18 +6,17 @@ */ package org.hibernate.search.integrationtest.java.modules.service.orm.elasticsearch.coordination.outboxpolling; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.awaitility.Awaitility.await; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import org.hibernate.search.integrationtest.java.modules.orm.elasticsearch.coordination.outboxpolling.service.AuthorService; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.util.common.SearchException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class JavaModulePathIT { +class JavaModulePathIT { /* * Test that the service successfully uses Hibernate Search in the module path. @@ -25,7 +24,7 @@ public class JavaModulePathIT { * but the easiest way to check this is to just use Hibernate Search features and see if it works. */ @Test - public void test() { + void test() { checkIsInModulePath( Object.class ); checkIsInModulePath( AuthorService.class ); checkIsInModulePath( Search.class ); @@ -36,7 +35,7 @@ public void test() { service.add( "foo bar" ); await().untilAsserted( () -> { - assertEquals( 2, service.search( "foo" ).size() ); + assertThat( service.search( "foo" ) ).hasSize( 2 ); } ); assertThatThrownBy( service::triggerValidationFailure ) @@ -49,9 +48,8 @@ public void test() { } private void checkIsInModulePath(Class clazz) { - assertTrue( - clazz + " should be part of a named module - there is a problem in test setup", - clazz.getModule().isNamed() - ); + assertThat( clazz.getModule().isNamed() ) + .as( clazz + " should be part of a named module - there is a problem in test setup" ) + .isTrue(); } } diff --git a/integrationtest/java/modules/orm-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/service/JavaModulePathIT.java b/integrationtest/java/modules/orm-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/service/JavaModulePathIT.java index 61afca82124..4131a03ca02 100644 --- a/integrationtest/java/modules/orm-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/service/JavaModulePathIT.java +++ b/integrationtest/java/modules/orm-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/orm/elasticsearch/service/JavaModulePathIT.java @@ -6,16 +6,15 @@ */ package org.hibernate.search.integrationtest.java.modules.orm.elasticsearch.service; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.util.common.SearchException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class JavaModulePathIT { +class JavaModulePathIT { /* * Test that the service successfully uses Hibernate Search in the module path. @@ -23,7 +22,7 @@ public class JavaModulePathIT { * but the easiest way to check this is to just use Hibernate Search features and see if it works. */ @Test - public void test() { + void test() { checkIsInModulePath( Object.class ); checkIsInModulePath( AuthorService.class ); checkIsInModulePath( Search.class ); @@ -32,7 +31,7 @@ public void test() { service.add( "foo" ); service.add( "bar" ); service.add( "foo bar" ); - assertEquals( 2, service.search( "foo" ).size() ); + assertThat( service.search( "foo" ) ).hasSize( 2 ); assertThatThrownBy( service::triggerValidationFailure ) .isInstanceOf( SearchException.class ) @@ -44,9 +43,8 @@ public void test() { } private void checkIsInModulePath(Class clazz) { - assertTrue( - clazz + " should be part of a named module - there is a problem in test setup", - clazz.getModule().isNamed() - ); + assertThat( clazz.getModule().isNamed() ) + .as( clazz + " should be part of a named module - there is a problem in test setup" ) + .isTrue(); } } diff --git a/integrationtest/java/modules/orm-lucene/src/test/java/org/hibernate/search/integrationtest/java/modules/orm/lucene/service/JavaModulePathIT.java b/integrationtest/java/modules/orm-lucene/src/test/java/org/hibernate/search/integrationtest/java/modules/orm/lucene/service/JavaModulePathIT.java index c14601e115b..304d57b15a8 100644 --- a/integrationtest/java/modules/orm-lucene/src/test/java/org/hibernate/search/integrationtest/java/modules/orm/lucene/service/JavaModulePathIT.java +++ b/integrationtest/java/modules/orm-lucene/src/test/java/org/hibernate/search/integrationtest/java/modules/orm/lucene/service/JavaModulePathIT.java @@ -6,14 +6,13 @@ */ package org.hibernate.search.integrationtest.java.modules.orm.lucene.service; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import org.hibernate.search.mapper.orm.Search; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class JavaModulePathIT { +class JavaModulePathIT { /* * Test that the service successfully uses Hibernate Search in the module path. @@ -21,7 +20,7 @@ public class JavaModulePathIT { * but the easiest way to check this is to just use Hibernate Search features and see if it works. */ @Test - public void test() { + void test() { checkIsInModulePath( Object.class ); checkIsInModulePath( AuthorService.class ); checkIsInModulePath( Search.class ); @@ -30,14 +29,13 @@ public void test() { service.add( "foo" ); service.add( "bar" ); service.add( "foo bar" ); - assertEquals( 2, service.search( "foo" ).size() ); + assertThat( service.search( "foo" ) ).hasSize( 2 ); } private void checkIsInModulePath(Class clazz) { - assertTrue( - clazz + " should be part of a named module - there is a problem in test setup", - clazz.getModule().isNamed() - ); + assertThat( clazz.getModule().isNamed() ) + .as( clazz + " should be part of a named module - there is a problem in test setup" ) + .isTrue(); } } diff --git a/integrationtest/java/modules/pojo-standalone-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/elasticsearch/service/JavaModulePathIT.java b/integrationtest/java/modules/pojo-standalone-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/elasticsearch/service/JavaModulePathIT.java index 9b309fb9b80..7929b0ce856 100644 --- a/integrationtest/java/modules/pojo-standalone-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/elasticsearch/service/JavaModulePathIT.java +++ b/integrationtest/java/modules/pojo-standalone-elasticsearch/src/test/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/elasticsearch/service/JavaModulePathIT.java @@ -6,14 +6,13 @@ */ package org.hibernate.search.integrationtest.java.modules.pojo.standalone.elasticsearch.service; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class JavaModulePathIT { +class JavaModulePathIT { /* * Test that the service successfully uses Hibernate Search in the module path. @@ -21,7 +20,7 @@ public class JavaModulePathIT { * but the easiest way to check this is to just use Hibernate Search features and see if it works. */ @Test - public void test() { + void test() { checkIsInModulePath( Object.class ); checkIsInModulePath( AuthorService.class ); checkIsInModulePath( SearchMapping.class ); @@ -30,14 +29,13 @@ public void test() { service.add( "foo" ); service.add( "bar" ); service.add( "foo bar" ); - assertEquals( 2, service.search( "foo" ).size() ); + assertThat( service.search( "foo" ) ).hasSize( 2 ); } private void checkIsInModulePath(Class clazz) { - assertTrue( - clazz + " should be part of a named module - there is a problem in test setup", - clazz.getModule().isNamed() - ); + assertThat( clazz.getModule().isNamed() ) + .as( clazz + " should be part of a named module - there is a problem in test setup" ) + .isTrue(); } } diff --git a/integrationtest/java/modules/pojo-standalone-lucene/src/test/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/lucene/service/JavaModulePathIT.java b/integrationtest/java/modules/pojo-standalone-lucene/src/test/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/lucene/service/JavaModulePathIT.java index 04b4c35ea49..5e1a30a2a36 100644 --- a/integrationtest/java/modules/pojo-standalone-lucene/src/test/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/lucene/service/JavaModulePathIT.java +++ b/integrationtest/java/modules/pojo-standalone-lucene/src/test/java/org/hibernate/search/integrationtest/java/modules/pojo/standalone/lucene/service/JavaModulePathIT.java @@ -6,14 +6,13 @@ */ package org.hibernate.search.integrationtest.java.modules.pojo.standalone.lucene.service; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class JavaModulePathIT { +class JavaModulePathIT { /* * Test that the service successfully uses Hibernate Search in the module path. @@ -21,7 +20,7 @@ public class JavaModulePathIT { * but the easiest way to check this is to just use Hibernate Search features and see if it works. */ @Test - public void test() { + void test() { checkIsInModulePath( Object.class ); checkIsInModulePath( AuthorService.class ); checkIsInModulePath( SearchSession.class ); @@ -30,13 +29,12 @@ public void test() { service.add( "foo" ); service.add( "bar" ); service.add( "foo bar" ); - assertEquals( 2, service.search( "foo" ).size() ); + assertThat( service.search( "foo" ) ).hasSize( 2 ); } private void checkIsInModulePath(Class clazz) { - assertTrue( - clazz + " should be part of a named module - there is a problem in test setup", - clazz.getModule().isNamed() - ); + assertThat( clazz.getModule().isNamed() ) + .as( clazz + " should be part of a named module - there is a problem in test setup" ) + .isTrue(); } } diff --git a/integrationtest/mapper/orm-cdi/src/test/java/org/hibernate/search/integrationtest/mapper/orm/cdi/CdiBeanResolutionIT.java b/integrationtest/mapper/orm-cdi/src/test/java/org/hibernate/search/integrationtest/mapper/orm/cdi/CdiBeanResolutionIT.java index 404958a8dcd..676993865ff 100644 --- a/integrationtest/mapper/orm-cdi/src/test/java/org/hibernate/search/integrationtest/mapper/orm/cdi/CdiBeanResolutionIT.java +++ b/integrationtest/mapper/orm-cdi/src/test/java/org/hibernate/search/integrationtest/mapper/orm/cdi/CdiBeanResolutionIT.java @@ -27,16 +27,16 @@ import org.hibernate.search.engine.environment.bean.BeanHolder; import org.hibernate.search.engine.environment.bean.BeanReference; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; @@ -53,21 +53,21 @@ "org.hibernate.search.test.integration.wildfly.cdi.CDIInjectionIT", "org.hibernate.search.test.integration.wildfly.cdi.CDIInjectionLifecycleEventsIT" }) -public class CdiBeanResolutionIT { +class CdiBeanResolutionIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); private SeContainer cdiContainer; - @Before - public void setup() { + @BeforeEach + void setup() { final SeContainerInitializer cdiInitializer = SeContainerInitializer.newInstance() .disableDiscovery() .addBeanClasses( @@ -80,15 +80,15 @@ public void setup() { this.cdiContainer = cdiInitializer.initialize(); } - @After - public void tearDown() { + @AfterEach + void tearDown() { if ( cdiContainer != null ) { cdiContainer.close(); } } @Test - public void singleton_byType() { + void singleton_byType() { doTest( ExpectedScope.SINGLETON, UnnamedSingletonBean.KEYS, BeanReference.of( UnnamedSingletonBean.class ) @@ -96,7 +96,7 @@ public void singleton_byType() { } @Test - public void singleton_byName() { + void singleton_byName() { doTest( ExpectedScope.SINGLETON, NamedSingletonBean.KEYS, BeanReference.of( InterfaceDefinedByMapper.class, NamedSingletonBean.NAME ) @@ -104,7 +104,7 @@ public void singleton_byName() { } @Test - public void dependent_byType() { + void dependent_byType() { doTest( ExpectedScope.DEPENDENT, UnnamedDependentBean.KEYS, BeanReference.of( UnnamedDependentBean.class ) @@ -112,7 +112,7 @@ public void dependent_byType() { } @Test - public void dependent_byName() { + void dependent_byName() { doTest( ExpectedScope.DEPENDENT, NamedDependentBean.KEYS, BeanReference.of( InterfaceDefinedByMapper.class, NamedDependentBean.NAME ) diff --git a/integrationtest/mapper/orm-cdi/src/test/java/org/hibernate/search/integrationtest/mapper/orm/cdi/CdiExtendedBeanManagerBootstrapShutdownIT.java b/integrationtest/mapper/orm-cdi/src/test/java/org/hibernate/search/integrationtest/mapper/orm/cdi/CdiExtendedBeanManagerBootstrapShutdownIT.java index 4f964fdf2f4..e3043d2b519 100644 --- a/integrationtest/mapper/orm-cdi/src/test/java/org/hibernate/search/integrationtest/mapper/orm/cdi/CdiExtendedBeanManagerBootstrapShutdownIT.java +++ b/integrationtest/mapper/orm-cdi/src/test/java/org/hibernate/search/integrationtest/mapper/orm/cdi/CdiExtendedBeanManagerBootstrapShutdownIT.java @@ -26,17 +26,17 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; @@ -45,29 +45,29 @@ * when using an {@link org.hibernate.resource.beans.container.spi.ExtendedBeanManager} in Hibernate ORM. */ @TestForIssue(jiraKey = { "HSEARCH-3938" }) -public class CdiExtendedBeanManagerBootstrapShutdownIT { +class CdiExtendedBeanManagerBootstrapShutdownIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule - public final StaticCounters counters = new StaticCounters(); + @RegisterExtension + public final StaticCounters counters = StaticCounters.create(); - @Rule + @RegisterExtension public final ExpectedLog4jLog logged = ExpectedLog4jLog.create(); private final StubExtendedBeanManager extendedBeanManager = new StubExtendedBeanManager(); - @After - public void tearDown() { + @AfterEach + void tearDown() { extendedBeanManager.cleanUp(); } @Test - public void successfulBoot() { + void successfulBoot() { List> retrievedBeans = new ArrayList<>(); backendMock.onCreate( context -> { @@ -120,7 +120,7 @@ public void successfulBoot() { } @Test - public void failedBoot() { + void failedBoot() { List> retrievedBeans = new ArrayList<>(); SearchException bootFailedException = new SearchException( "Simulated boot failure" ); @@ -178,7 +178,7 @@ public void failedBoot() { } @Test - public void cancelledBoot() { + void cancelledBoot() { List> retrievedBeans = new ArrayList<>(); backendMock.onCreate( context -> { @@ -217,7 +217,7 @@ public void cancelledBoot() { } @Test - public void failedShutdown() { + void failedShutdown() { List> retrievedBeans = new ArrayList<>(); SearchException bootFailedException = new SearchException( "Simulated shutdown failure" ); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/pom.xml b/integrationtest/mapper/orm-coordination-outbox-polling/pom.xml index 11af0318c9a..ebb19803832 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/pom.xml +++ b/integrationtest/mapper/orm-coordination-outbox-polling/pom.xml @@ -52,11 +52,6 @@ ${jdbc.driver.artifactId} test - - io.takari.junit - takari-cpsuite - test - diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/OutboxPollingDisabledIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/OutboxPollingDisabledIT.java index d263811c50c..1c0e92d7732 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/OutboxPollingDisabledIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/OutboxPollingDisabledIT.java @@ -22,7 +22,7 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.event.impl.OutboxEvent; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -53,7 +53,7 @@ public static Object[][] params() { } @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ) diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/OutboxPollingStrategyPropertyValueIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/OutboxPollingStrategyPropertyValueIT.java index 72806b93cd0..005769ee9c6 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/OutboxPollingStrategyPropertyValueIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/OutboxPollingStrategyPropertyValueIT.java @@ -29,7 +29,7 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.event.impl.OutboxEvent; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -67,7 +67,7 @@ public static List params() { private static final OutboxEventFilter eventFilter = new OutboxEventFilter(); @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ) diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingBackendFailureIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingBackendFailureIT.java index 393bf489c75..603d651eb0c 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingBackendFailureIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingBackendFailureIT.java @@ -29,24 +29,24 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.awaitility.core.ThrowingRunnable; /** * Extensive tests of backend failures for automatic indexing with outbox-polling. */ -public class OutboxPollingAutomaticIndexingBackendFailureIT { +class OutboxPollingAutomaticIndexingBackendFailureIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); @@ -58,7 +58,7 @@ public class OutboxPollingAutomaticIndexingBackendFailureIT { private TestFailureHandler failureHandler; @Test - public void backendFailure() { + void backendFailure() { setup( 0 ); with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); @@ -110,7 +110,7 @@ public void backendFailure() { } @Test - public void backendFailure_retryAfter() { + void backendFailure_retryAfter() { setup( 3 ); AtomicLong timeOfTheException = new AtomicLong(); with( sessionFactory ).runInTransaction( session -> { @@ -166,7 +166,7 @@ public void backendFailure_retryAfter() { } @Test - public void backendFailure_twoFailuresOfTheSameIndexingWork() { + void backendFailure_twoFailuresOfTheSameIndexingWork() { setup( 0 ); with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); @@ -225,7 +225,7 @@ public void backendFailure_twoFailuresOfTheSameIndexingWork() { } @Test - public void backendFailure_numberOfTrialsExhausted() { + void backendFailure_numberOfTrialsExhausted() { setup( 0 ); with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingConcurrencyIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingConcurrencyIT.java index b86e3b7244c..fc97e0fdee0 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingConcurrencyIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingConcurrencyIT.java @@ -25,15 +25,15 @@ import org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util.TestFailureHandler; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests highly concurrent background processing of events, @@ -42,29 +42,29 @@ * This used to fail on Microsoft SQL Server, in particular, because of its lock escalation mechanism. */ @TestForIssue(jiraKey = "HSEARCH-4141") -public class OutboxPollingAutomaticIndexingConcurrencyIT { +class OutboxPollingAutomaticIndexingConcurrencyIT { public static final int TOTAL_SHARD_COUNT = 23; public static final int ENTITY_COUNT = 2000; // Experimentation showed that larger batch sizes tend to reproduce the deadlock more reliably. public static final int ENTITY_UPDATE_BATCH_SIZE = 500; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); private final TestFailureHandler failureHandler = new TestFailureHandler(); private final List sessionFactories = new ArrayList<>(); - @Before - public void setup() { + @BeforeEach + void setup() { sessionFactories.add( setup( "create-drop" ) ); for ( int i = 1; i < TOTAL_SHARD_COUNT; i++ ) { // Avoid session factories stepping on each other's feet: use Action.NONE here. @@ -94,7 +94,7 @@ private SessionFactory setup(String hbm2ddlAction) { // and indeed for most databases they will not due to how our queries are designed, // but on some databases (CockroachDB) that's very hard (impossible?) to achieve. @Test - public void resilientToTransactionDeadlocks() { + void resilientToTransactionDeadlocks() { SessionFactory sessionFactory = sessionFactories.get( 0 ); Dialect dialect = sessionFactory.unwrap( SessionFactoryImplementor.class ).getJdbcServices().getDialect(); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingDynamicShardingRebalancingIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingDynamicShardingRebalancingIT.java index 2fd3f45f59b..de128ef1c3c 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingDynamicShardingRebalancingIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingDynamicShardingRebalancingIT.java @@ -28,20 +28,20 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cfg.impl.HibernateOrmMapperOutboxPollingImplSettings; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test of automatic rebalancing for dynamic sharding with the outbox-polling coordination strategy. */ @TestForIssue(jiraKey = "HSEARCH-4140") -public class OutboxPollingAutomaticIndexingDynamicShardingRebalancingIT { +class OutboxPollingAutomaticIndexingDynamicShardingRebalancingIT { // Use a low polling interval, pulse interval and batch size when testing rebalancing // so that we can observe rebalancing on a reasonably small timescale. @@ -52,15 +52,15 @@ public class OutboxPollingAutomaticIndexingDynamicShardingRebalancingIT { // or agents will be likely to expire while processing a single batch. private static final int PULSE_EXPIRATION = 5000; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); private final PerSessionFactoryIndexingCountHelper indexingCountHelper = new PerSessionFactoryIndexingCountHelper( counters ); @@ -102,7 +102,7 @@ private void setup(String hbm2ddlAction) { } @Test - public void agentLeft() { + void agentLeft() { setup(); SessionFactory sessionFactory = indexingCountHelper.sessionFactory( 0 ); @@ -151,7 +151,7 @@ public void agentLeft() { } @Test - public void agentExpired() { + void agentExpired() { setup(); SessionFactory sessionFactory = indexingCountHelper.sessionFactory( 0 ); @@ -194,7 +194,7 @@ public void agentExpired() { } @Test - public void agentJoined() { + void agentJoined() { setup(); SessionFactory sessionFactory = indexingCountHelper.sessionFactory( 0 ); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingEdgeCasesIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingEdgeCasesIT.java index 2ab81f03b29..c1b7e2f40e9 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingEdgeCasesIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingEdgeCasesIT.java @@ -23,7 +23,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -42,7 +43,7 @@ public class OutboxPollingAutomaticIndexingEdgeCasesIT { private static final OutboxEventFilter eventFilter = new OutboxEventFilter(); @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ) diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingEventSendingIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingEventSendingIT.java index 5be27a36e44..df335a403a3 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingEventSendingIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingEventSendingIT.java @@ -31,7 +31,7 @@ import org.hibernate.search.mapper.pojo.route.DocumentRouteDescriptor; import org.hibernate.search.mapper.pojo.route.DocumentRoutesDescriptor; import org.hibernate.search.mapper.pojo.work.spi.PojoIndexingQueueEventPayload; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -48,7 +48,7 @@ public class OutboxPollingAutomaticIndexingEventSendingIT { private static final OutboxEventFilter eventFilter = new OutboxEventFilter(); @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ) diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingInvalidConfigurationIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingInvalidConfigurationIT.java index 8476583479c..9d55c7cef25 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingInvalidConfigurationIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingInvalidConfigurationIT.java @@ -18,27 +18,27 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4140") -public class OutboxPollingAutomaticIndexingInvalidConfigurationIT { +class OutboxPollingAutomaticIndexingInvalidConfigurationIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); @Test - public void pulseInterval_negative() { + void pulseInterval_negative() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.pulse_interval", "-1" ) ) ) .isInstanceOf( SearchException.class ) @@ -49,7 +49,7 @@ public void pulseInterval_negative() { } @Test - public void pulseInterval_zero() { + void pulseInterval_zero() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.pulse_interval", "0" ) ) ) .isInstanceOf( SearchException.class ) @@ -60,7 +60,7 @@ public void pulseInterval_zero() { } @Test - public void pulseInterval_lowerThanPollingInterval() { + void pulseInterval_lowerThanPollingInterval() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.pulse_interval", "40" ) .withProperty( "hibernate.search.coordination.event_processor.polling_interval", "50" ) ) ) @@ -73,7 +73,7 @@ public void pulseInterval_lowerThanPollingInterval() { } @Test - public void pulseExpiration_negative() { + void pulseExpiration_negative() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.pulse_expiration", "-1" ) ) ) .isInstanceOf( SearchException.class ) @@ -84,7 +84,7 @@ public void pulseExpiration_negative() { } @Test - public void pulseExpiration_zero() { + void pulseExpiration_zero() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.pulse_expiration", "0" ) ) ) .isInstanceOf( SearchException.class ) @@ -95,7 +95,7 @@ public void pulseExpiration_zero() { } @Test - public void pulseExpiration_lowerThan3TimesPollingInterval() { + void pulseExpiration_lowerThan3TimesPollingInterval() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.pulse_expiration", "599" ) .withProperty( "hibernate.search.coordination.event_processor.pulse_interval", "200" ) ) ) diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingLifecycleIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingLifecycleIT.java index 1a3f1bacf25..e96a1679651 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingLifecycleIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingLifecycleIT.java @@ -24,37 +24,37 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.event.impl.OutboxEvent; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class OutboxPollingAutomaticIndexingLifecycleIT { +class OutboxPollingAutomaticIndexingLifecycleIT { // The value doesn't matter, we just need to be sure that's the one that was configured. private static final long BATCH_SIZE = HibernateOrmMapperOutboxPollingSettings.Defaults.COORDINATION_EVENT_PROCESSOR_BATCH_SIZE; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); private final OutboxEventFilter eventFilter = new OutboxEventFilter(); - @Before - public void cleanUp() { + @BeforeEach + void cleanUp() { SessionFactory sessionFactory = setupWithCleanup(); sessionFactory.close(); } @Test - public void stopWhileOutboxEventsIsBeingProcessed() { + void stopWhileOutboxEventsIsBeingProcessed() { SessionFactory sessionFactory = setup(); backendMock.verifyExpectationsMet(); int size = 10000; @@ -108,7 +108,7 @@ public void stopWhileOutboxEventsIsBeingProcessed() { } @Test - public void processCreateUpdateDelete() { + void processCreateUpdateDelete() { SessionFactory sessionFactory = setup(); backendMock.verifyExpectationsMet(); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingMultiTenancyIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingMultiTenancyIT.java index 1229ab7a706..ed02c856555 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingMultiTenancyIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingMultiTenancyIT.java @@ -21,14 +21,14 @@ import org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util.PerSessionFactoryIndexingCountHelper; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.data.Percentage; @@ -37,21 +37,21 @@ * with configuration specific to the outbox-polling coordination strategy. */ @TestForIssue(jiraKey = "HSEARCH-4316") -public class OutboxPollingAutomaticIndexingMultiTenancyIT { +class OutboxPollingAutomaticIndexingMultiTenancyIT { private static final String TENANT_1_ID = "tenant1"; private static final String TENANT_2_ID = "tenant2"; private static final String TENANT_3_ID = "tenant3"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); private final PerSessionFactoryIndexingCountHelper indexingCountHelper = new PerSessionFactoryIndexingCountHelper( counters ); @@ -71,7 +71,7 @@ private void setup(String hbm2ddlAction, UnaryOperator c ); // Session factory 1 is configured to handle tenant 1 only diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingOutOfOrderIdsIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingOutOfOrderIdsIT.java index 0a2496f51f2..f14a1166003 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingOutOfOrderIdsIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingOutOfOrderIdsIT.java @@ -31,16 +31,16 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.event.impl.OutboxEvent; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class OutboxPollingAutomaticIndexingOutOfOrderIdsIT { +class OutboxPollingAutomaticIndexingOutOfOrderIdsIT { private static final String OUTBOX_EVENT_UPDATE_ID_AND_TIME = "UPDATE HSEARCH_OUTBOX_EVENT SET ID = ?, PROCESSAFTER = ? WHERE ID = ?"; @@ -50,17 +50,17 @@ public class OutboxPollingAutomaticIndexingOutOfOrderIdsIT { private final OutboxEventFilter eventFilter = new OutboxEventFilter(); - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); private SessionFactory sessionFactory; - @Before - public void before() { + @BeforeEach + void before() { backendMock.expectAnySchema( IndexedEntity.INDEX ) .expectAnySchema( RoutedIndexedEntity.NAME ); sessionFactory = ormSetupHelper.start() @@ -76,7 +76,7 @@ public void before() { } @Test - public void processCreateUpdateDelete() { + void processCreateUpdateDelete() { // An entity is created, updated, then deleted in separate transactions, // but the delete event has ID 1, the update event has ID 2, and the add event has ID 3. @@ -145,7 +145,7 @@ public void processCreateUpdateDelete() { } @Test - public void processDeleteRecreate_rightOrder() { + void processDeleteRecreate_rightOrder() { // An entity is deleted, then re-created in separate transactions. int id = 1; @@ -179,7 +179,7 @@ public void processDeleteRecreate_rightOrder() { } @Test - public void processDeleteRecreate_outOfOrder() { + void processDeleteRecreate_outOfOrder() { // An entity is deleted, then re-created in separate transactions, // but the add event has ID 1, the and the delete event has ID 2. @@ -240,7 +240,7 @@ public void processDeleteRecreate_outOfOrder() { } @Test - public void processDifferentRoutesUpdates() { + void processDifferentRoutesUpdates() { // An entity is updated twice in two separate transactions, // resulting in two events with different routing keys @@ -287,7 +287,7 @@ public void processDifferentRoutesUpdates() { } @Test - public void processDifferentRoutesUpdates_outOfOrder() { + void processDifferentRoutesUpdates_outOfOrder() { // An entity is updated twice in two separate transactions, // resulting in two events with different routing keys, // but the second update event has ID 1, and the first update has ID 2. diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingProcessingOrderIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingProcessingOrderIT.java index 3fb5046421a..7403e518d14 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingProcessingOrderIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingProcessingOrderIT.java @@ -26,30 +26,30 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.ListAssert; -public class OutboxPollingAutomaticIndexingProcessingOrderIT { +class OutboxPollingAutomaticIndexingProcessingOrderIT { private static final String OUTBOX_EVENT_TABLE_NAME = HibernateOrmMapperOutboxPollingSettings.Defaults.COORDINATION_ENTITY_MAPPING_OUTBOX_EVENT_TABLE; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); @Test - public void invalid() { + void invalid() { backendMock.expectAnySchema( IndexedEntity.NAME ); assertThatThrownBy( () -> ormSetupHelper.start() .withProperty( "hibernate.search.coordination.event_processor.order", "someinvalidstring" ) @@ -63,7 +63,7 @@ public void invalid() { } @Test - public void default_randomUuid() { + void default_randomUuid() { StatementSpy spy = new StatementSpy(); backendMock.expectAnySchema( IndexedEntity.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() @@ -85,7 +85,7 @@ public void default_randomUuid() { } @Test - public void default_timeUuid() { + void default_timeUuid() { StatementSpy spy = new StatementSpy(); backendMock.expectAnySchema( IndexedEntity.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() @@ -99,7 +99,7 @@ public void default_timeUuid() { } @Test - public void auto_randomUuid() { + void auto_randomUuid() { StatementSpy spy = new StatementSpy(); backendMock.expectAnySchema( IndexedEntity.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() @@ -122,7 +122,7 @@ public void auto_randomUuid() { } @Test - public void auto_timeUuid() { + void auto_timeUuid() { StatementSpy spy = new StatementSpy(); backendMock.expectAnySchema( IndexedEntity.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() @@ -137,7 +137,7 @@ public void auto_timeUuid() { } @Test - public void none() { + void none() { StatementSpy spy = new StatementSpy(); backendMock.expectAnySchema( IndexedEntity.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() @@ -152,7 +152,7 @@ public void none() { } @Test - public void time() { + void time() { StatementSpy spy = new StatementSpy(); backendMock.expectAnySchema( IndexedEntity.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() @@ -166,7 +166,7 @@ public void time() { } @Test - public void id() { + void id() { StatementSpy spy = new StatementSpy(); backendMock.expectAnySchema( IndexedEntity.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingRoutingIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingRoutingIT.java index e23a6aaf7a1..2bb61ea1f39 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingRoutingIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingRoutingIT.java @@ -16,22 +16,22 @@ import org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util.OutboxEventFilter; import org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util.TestingOutboxPollingInternalConfigurer; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cfg.impl.HibernateOrmMapperOutboxPollingImplSettings; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class OutboxPollingAutomaticIndexingRoutingIT { +class OutboxPollingAutomaticIndexingRoutingIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); @@ -39,8 +39,8 @@ public class OutboxPollingAutomaticIndexingRoutingIT { private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( RoutedIndexedEntity.NAME ); sessionFactory = setupHelper.start() .withProperty( HibernateOrmMapperOutboxPollingImplSettings.COORDINATION_INTERNAL_CONFIGURER, @@ -51,7 +51,7 @@ public void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-4186") - public void processingEventsWithOutdatedRoutingKey() { + void processingEventsWithOutdatedRoutingKey() { with( sessionFactory ).runInTransaction( session -> { RoutedIndexedEntity entity = new RoutedIndexedEntity( 1, "first", RoutedIndexedEntity.Status.FIRST ); session.persist( entity ); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingShardingBaseIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingShardingBaseIT.java index 5ca8685cf50..e5cc9aa8042 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingShardingBaseIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingShardingBaseIT.java @@ -10,6 +10,9 @@ import static org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util.OutboxPollingTestUtils.awaitAllAgentsRunningInOneCluster; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; +import java.util.Arrays; +import java.util.List; + import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.OneToOne; @@ -20,17 +23,16 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.assertj.core.data.Percentage; @@ -39,43 +41,34 @@ * checks that all events are handled by one and only one node * (if they were not, we would see missing or duplicate indexing work executions). */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = { "HSEARCH-4141", "HSEARCH-4140" }) -public class OutboxPollingAutomaticIndexingShardingBaseIT { - - @Parameterized.Parameters(name = "static = {0}, totalShardCount = {1}") - public static Object[][] params() { - return new Object[][] { - { false, 2 }, - { true, 2 }, - { false, 10 }, - { true, 10 }, - }; +class OutboxPollingAutomaticIndexingShardingBaseIT { + + public static List params() { + return Arrays.asList( + Arguments.of( false, 2 ), + Arguments.of( true, 2 ), + Arguments.of( false, 10 ), + Arguments.of( true, 10 ) + ); } - @Parameterized.Parameter - public boolean isStatic; - - @Parameterized.Parameter(1) - public int totalShardCount; - - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); private final PerSessionFactoryIndexingCountHelper indexingCountHelper = new PerSessionFactoryIndexingCountHelper( counters ); - @Before - public void setup() { + public void setup(boolean isStatic, int totalShardCount) { for ( int i = 0; i < totalShardCount; i++ ) { - setup( + setup( isStatic, totalShardCount, // Avoid session factories stepping on each other's feet. i == 0 ? "create-drop" : "none", i @@ -87,7 +80,7 @@ public void setup() { awaitAllAgentsRunningInOneCluster( with( indexingCountHelper.sessionFactory( 0 ) ), totalShardCount ); } - private void setup(String hbm2ddlAction, int assignedShardIndex) { + private void setup(boolean isStatic, int totalShardCount, String hbm2ddlAction, int assignedShardIndex) { backendMock.expectSchema( IndexedEntity.NAME, b -> b .field( "text", String.class, f -> f.analyzerName( AnalyzerNames.DEFAULT ) ) .with( indexingCountHelper::expectSchema ) @@ -117,8 +110,10 @@ private void setup(String hbm2ddlAction, int assignedShardIndex) { .setup( IndexedEntity.class, IndexedAndContainingEntity.class, ContainedEntity.class ); } - @Test - public void uniqueWorkAcrossSessionFactories_insertUpdateDelete_indexed() { + @ParameterizedTest(name = "static = {0}, totalShardCount = {1}") + @MethodSource("params") + void uniqueWorkAcrossSessionFactories_insertUpdateDelete_indexed(boolean isStatic, int totalShardCount) { + setup( isStatic, totalShardCount ); SessionFactory sessionFactory = indexingCountHelper.sessionFactory( 0 ); with( sessionFactory ).runInTransaction( session -> { @@ -151,8 +146,10 @@ public void uniqueWorkAcrossSessionFactories_insertUpdateDelete_indexed() { indexingCountHelper.indexingCounts().assertAcrossAllSessionFactories().isEqualTo( 2 ); } - @Test - public void uniqueWorkAcrossSessionFactories_insertUpdateDelete_contained() { + @ParameterizedTest(name = "static = {0}, totalShardCount = {1}") + @MethodSource("params") + void uniqueWorkAcrossSessionFactories_insertUpdateDelete_contained(boolean isStatic, int totalShardCount) { + setup( isStatic, totalShardCount ); SessionFactory sessionFactory = indexingCountHelper.sessionFactory( 0 ); with( sessionFactory ).runInTransaction( session -> { @@ -195,8 +192,10 @@ public void uniqueWorkAcrossSessionFactories_insertUpdateDelete_contained() { indexingCountHelper.indexingCounts().assertAcrossAllSessionFactories().isEqualTo( 3 ); } - @Test - public void uniformWorkDistribution_insertUpdateDelete_indexed() { + @ParameterizedTest(name = "static = {0}, totalShardCount = {1}") + @MethodSource("params") + void uniformWorkDistribution_insertUpdateDelete_indexed(boolean isStatic, int totalShardCount) { + setup( isStatic, totalShardCount ); SessionFactory sessionFactory = indexingCountHelper.sessionFactory( 0 ); int entityCount = 1000; diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingIncompatibleConfigurationIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingIncompatibleConfigurationIT.java index d569927d2f0..3274afdade8 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingIncompatibleConfigurationIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingIncompatibleConfigurationIT.java @@ -20,29 +20,29 @@ import org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util.TestFailureHandler; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test for static sharding where some nodes are configured in an incompatible way. */ @TestForIssue(jiraKey = "HSEARCH-4140") -public class OutboxPollingAutomaticIndexingStaticShardingIncompatibleConfigurationIT { +class OutboxPollingAutomaticIndexingStaticShardingIncompatibleConfigurationIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); private void setup(String hbm2ddlAction, TestFailureHandler failureHandler, int totalShardCount, @@ -61,7 +61,7 @@ private void setup(String hbm2ddlAction, TestFailureHandler failureHandler, int } @Test - public void conflictingTotalShardCount() throws InterruptedException { + void conflictingTotalShardCount() throws InterruptedException { TestFailureHandler sessionFactory1FailureHandler = new TestFailureHandler(); TestFailureHandler sessionFactory2FailureHandler = new TestFailureHandler(); @@ -101,7 +101,7 @@ public void conflictingTotalShardCount() throws InterruptedException { } @Test - public void conflictingAssignedShardIndex() throws InterruptedException { + void conflictingAssignedShardIndex() throws InterruptedException { TestFailureHandler sessionFactory1FailureHandler = new TestFailureHandler(); TestFailureHandler sessionFactory2FailureHandler = new TestFailureHandler(); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingInvalidConfigurationIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingInvalidConfigurationIT.java index 4d30685cba2..d73fbb1b6c9 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingInvalidConfigurationIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingInvalidConfigurationIT.java @@ -17,27 +17,27 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4141") -public class OutboxPollingAutomaticIndexingStaticShardingInvalidConfigurationIT { +class OutboxPollingAutomaticIndexingStaticShardingInvalidConfigurationIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); @Test - public void totalCount_missing() { + void totalCount_missing() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.shards.assigned", "0" ) ) ) .isInstanceOf( SearchException.class ) @@ -49,7 +49,7 @@ public void totalCount_missing() { } @Test - public void totalCount_zero() { + void totalCount_zero() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.shards.total_count", "0" ) ) ) .isInstanceOf( SearchException.class ) @@ -60,7 +60,7 @@ public void totalCount_zero() { } @Test - public void totalCount_negative() { + void totalCount_negative() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.shards.total_count", "-1" ) ) ) .isInstanceOf( SearchException.class ) @@ -71,7 +71,7 @@ public void totalCount_negative() { } @Test - public void assigned_missing() { + void assigned_missing() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.shards.total_count", "10" ) ) ) .isInstanceOf( SearchException.class ) @@ -83,7 +83,7 @@ public void assigned_missing() { } @Test - public void assigned_negative() { + void assigned_negative() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.shards.total_count", "10" ) .withProperty( "hibernate.search.coordination.event_processor.shards.assigned", "-1" ) ) ) @@ -96,7 +96,7 @@ public void assigned_negative() { } @Test - public void assigned_equalToTotalCount() { + void assigned_equalToTotalCount() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.shards.total_count", "10" ) .withProperty( "hibernate.search.coordination.event_processor.shards.assigned", "10" ) ) ) @@ -110,7 +110,7 @@ public void assigned_equalToTotalCount() { } @Test - public void assigned_greaterThanTotalCount() { + void assigned_greaterThanTotalCount() { assertThatThrownBy( () -> setup( context -> context .withProperty( "hibernate.search.coordination.event_processor.shards.total_count", "10" ) .withProperty( "hibernate.search.coordination.event_processor.shards.assigned", "11" ) ) ) diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingUnevenShardsIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingUnevenShardsIT.java index 663e19c0dfa..94ccfe89617 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingUnevenShardsIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingAutomaticIndexingStaticShardingUnevenShardsIT.java @@ -21,15 +21,15 @@ import org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util.PerSessionFactoryIndexingCountHelper; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.data.Percentage; @@ -38,25 +38,25 @@ * where each nodes are assigned a different number of shards (some 1, some 0, some more than 1, ...). */ @TestForIssue(jiraKey = "HSEARCH-4141") -public class OutboxPollingAutomaticIndexingStaticShardingUnevenShardsIT { +class OutboxPollingAutomaticIndexingStaticShardingUnevenShardsIT { public static final int TOTAL_SHARD_COUNT = 7; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); private final PerSessionFactoryIndexingCountHelper indexingCountHelper = new PerSessionFactoryIndexingCountHelper( counters ); - @Before - public void setup() { + @BeforeEach + void setup() { setup( "create-drop", true, Collections.singletonList( 0 ) // 1 shard @@ -103,7 +103,7 @@ private void setup(String hbm2ddlAction, boolean processingEnabled, List b .field( "text", String.class, f -> f.analyzerName( AnalyzerNames.DEFAULT ) ) ); @@ -106,7 +106,7 @@ public void singleTenant() throws InterruptedException { } @Test - public void multiTenant() throws InterruptedException { + void multiTenant() throws InterruptedException { String tenant1Id = "tenant1"; String tenant2Id = "tenant2"; diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingIndexingPlanFilterIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingIndexingPlanFilterIT.java index 5d47a44dca0..7d98e9d1e5d 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingIndexingPlanFilterIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/automaticindexing/OutboxPollingIndexingPlanFilterIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.automaticindexing; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import jakarta.persistence.Basic; import jakarta.persistence.Entity; @@ -18,7 +18,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -31,7 +31,7 @@ public class OutboxPollingIndexingPlanFilterIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/AbortedEventsGenerator.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/AbortedEventsGenerator.java index 585f8150497..16d3e5188d6 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/AbortedEventsGenerator.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/AbortedEventsGenerator.java @@ -16,7 +16,7 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; public class AbortedEventsGenerator { private static final AtomicInteger ID_GENERATOR = new AtomicInteger( 1 ); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/OutboxPollingSearchMappingIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/OutboxPollingSearchMappingIT.java index 4058ed40a8a..90955566331 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/OutboxPollingSearchMappingIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/OutboxPollingSearchMappingIT.java @@ -16,20 +16,20 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.OutboxPollingExtension; import org.hibernate.search.mapper.orm.coordination.outboxpolling.mapping.OutboxPollingSearchMapping; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class OutboxPollingSearchMappingIT { +class OutboxPollingSearchMappingIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); @@ -37,8 +37,8 @@ public class OutboxPollingSearchMappingIT { private OutboxPollingSearchMapping searchMapping; private AbortedEventsGenerator abortedEventsGenerator; - @Before - public void before() { + @BeforeEach + void before() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b.field( "indexedField", String.class ) ); sessionFactory = ormSetupHelper.start() .withProperty( "hibernate.search.coordination.event_processor.retry_delay", 0 ) @@ -49,7 +49,7 @@ public void before() { } @Test - public void countAbortedEvents_tenantIdSpecified() { + void countAbortedEvents_tenantIdSpecified() { assertThatThrownBy( () -> searchMapping.countAbortedEvents( "tenantX" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -59,7 +59,7 @@ public void countAbortedEvents_tenantIdSpecified() { } @Test - public void reprocessAbortedEvents_tenantIdSpecified() { + void reprocessAbortedEvents_tenantIdSpecified() { assertThatThrownBy( () -> searchMapping.reprocessAbortedEvents( "tenantX" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -69,7 +69,7 @@ public void reprocessAbortedEvents_tenantIdSpecified() { } @Test - public void clearAllAbortedEvents_tenantIdSpecified() { + void clearAllAbortedEvents_tenantIdSpecified() { assertThatThrownBy( () -> searchMapping.clearAllAbortedEvents( "tenantX" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -79,7 +79,7 @@ public void clearAllAbortedEvents_tenantIdSpecified() { } @Test - public void clearAllAbortedEvents() { + void clearAllAbortedEvents() { assertThat( searchMapping.countAbortedEvents() ).isZero(); abortedEventsGenerator.generateThreeAbortedEvents(); @@ -92,7 +92,7 @@ public void clearAllAbortedEvents() { } @Test - public void reprocessAbortedEvents() { + void reprocessAbortedEvents() { assertThat( searchMapping.countAbortedEvents() ).isZero(); List generatedIDs = abortedEventsGenerator.generateThreeAbortedEvents(); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/OutboxPollingSearchMappingMultiTenancyIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/OutboxPollingSearchMappingMultiTenancyIT.java index bbae3c604e9..9cbe9e8ad9a 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/OutboxPollingSearchMappingMultiTenancyIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/mapping/OutboxPollingSearchMappingMultiTenancyIT.java @@ -9,6 +9,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import java.util.Arrays; import java.util.List; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -19,26 +20,31 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.OutboxPollingExtension; import org.hibernate.search.mapper.orm.coordination.outboxpolling.mapping.OutboxPollingSearchMapping; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +class OutboxPollingSearchMappingMultiTenancyIT { -@RunWith(Parameterized.class) -public class OutboxPollingSearchMappingMultiTenancyIT { private static final String TENANT_1_ID = "tenant1"; private static final String TENANT_2_ID = "tenant2"; private static final String TENANT_3_ID = "tenant3"; - @Parameterized.Parameters(name = "entity = {0}") - public static Object[][] params() { - return new Object[][] { - { + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); + + @RegisterExtension + public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) + .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); + + public static List params() { + return Arrays.asList( + Arguments.of( IndexedMultiTenantEntity.INDEX, IndexedMultiTenantEntity.class, (BiConsumer) (session, id) -> { @@ -49,8 +55,8 @@ public static Object[][] params() { }, (Consumer) context -> context.tenants( false, TENANT_1_ID, TENANT_2_ID, TENANT_3_ID ) - }, - { + ), + Arguments.of( IndexedEntity.INDEX, IndexedEntity.class, (BiConsumer) (session, id) -> { @@ -62,36 +68,17 @@ public static Object[][] params() { (Consumer) context -> { context.tenants( TENANT_1_ID, TENANT_2_ID, TENANT_3_ID ); } - }, - }; + ) + ); } - @Rule - public BackendMock backendMock = new BackendMock(); - - @Rule - public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) - .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); - private SessionFactory sessionFactory; private OutboxPollingSearchMapping searchMapping; private AbortedEventsGenerator abortedEventsGenerator1; private AbortedEventsGenerator abortedEventsGenerator2; - @Parameterized.Parameter(0) - public String indexName; - - @Parameterized.Parameter(1) - public Class indexedEntity; - - @Parameterized.Parameter(2) - public BiConsumer entityCreator; - - @Parameterized.Parameter(3) - public Consumer tenantConfigurer; - - @Before - public void before() { + void init(String indexName, Class indexedEntity, BiConsumer entityCreator, + Consumer tenantConfigurer) { backendMock.expectSchema( indexName, b -> b.field( "indexedField", String.class ) ); OrmSetupHelper.SetupContext setupContext = ormSetupHelper.start(); tenantConfigurer.accept( setupContext ); @@ -106,8 +93,11 @@ public void before() { new AbortedEventsGenerator( sessionFactory, backendMock, TENANT_2_ID, indexName, entityCreator ); } - @Test - public void countAbortedEvents_noTenantIdSpecified() { + @ParameterizedTest(name = "entity = {0}") + @MethodSource("params") + void ountAbortedEvents_noTenantIdSpecified(String indexName, Class indexedEntity, + BiConsumer entityCreator, Consumer tenantConfigurer) { + init( indexName, indexedEntity, entityCreator, tenantConfigurer ); assertThatThrownBy( () -> searchMapping.countAbortedEvents() ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -116,8 +106,11 @@ public void countAbortedEvents_noTenantIdSpecified() { ); } - @Test - public void countAbortedEvents_wrongTenantId() { + @ParameterizedTest(name = "entity = {0}") + @MethodSource("params") + void countAbortedEvents_wrongTenantId(String indexName, Class indexedEntity, + BiConsumer entityCreator, Consumer tenantConfigurer) { + init( indexName, indexedEntity, entityCreator, tenantConfigurer ); assertThatThrownBy( () -> searchMapping.countAbortedEvents( "tenantX" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -126,8 +119,11 @@ public void countAbortedEvents_wrongTenantId() { ); } - @Test - public void reprocessAbortedEvents_noTenantIdSpecified() { + @ParameterizedTest(name = "entity = {0}") + @MethodSource("params") + void reprocessAbortedEvents_noTenantIdSpecified(String indexName, Class indexedEntity, + BiConsumer entityCreator, Consumer tenantConfigurer) { + init( indexName, indexedEntity, entityCreator, tenantConfigurer ); assertThatThrownBy( () -> searchMapping.reprocessAbortedEvents() ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -136,8 +132,11 @@ public void reprocessAbortedEvents_noTenantIdSpecified() { ); } - @Test - public void reprocessAbortedEvents_wrongTenantId() { + @ParameterizedTest(name = "entity = {0}") + @MethodSource("params") + void reprocessAbortedEvents_wrongTenantId(String indexName, Class indexedEntity, + BiConsumer entityCreator, Consumer tenantConfigurer) { + init( indexName, indexedEntity, entityCreator, tenantConfigurer ); assertThatThrownBy( () -> searchMapping.reprocessAbortedEvents( "tenantX" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -146,8 +145,11 @@ public void reprocessAbortedEvents_wrongTenantId() { ); } - @Test - public void clearAllAbortedEvents_noTenantIdSpecified() { + @ParameterizedTest(name = "entity = {0}") + @MethodSource("params") + void clearAllAbortedEvents_noTenantIdSpecified(String indexName, Class indexedEntity, + BiConsumer entityCreator, Consumer tenantConfigurer) { + init( indexName, indexedEntity, entityCreator, tenantConfigurer ); assertThatThrownBy( () -> searchMapping.clearAllAbortedEvents() ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -156,8 +158,11 @@ public void clearAllAbortedEvents_noTenantIdSpecified() { ); } - @Test - public void clearAllAbortedEvents_wrongTenantId() { + @ParameterizedTest(name = "entity = {0}") + @MethodSource("params") + void clearAllAbortedEvents_wrongTenantId(String indexName, Class indexedEntity, + BiConsumer entityCreator, Consumer tenantConfigurer) { + init( indexName, indexedEntity, entityCreator, tenantConfigurer ); assertThatThrownBy( () -> searchMapping.clearAllAbortedEvents( "tenantX" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -166,8 +171,11 @@ public void clearAllAbortedEvents_wrongTenantId() { ); } - @Test - public void clearAllAbortedEvents() { + @ParameterizedTest(name = "entity = {0}") + @MethodSource("params") + void clearAllAbortedEvents(String indexName, Class indexedEntity, + BiConsumer entityCreator, Consumer tenantConfigurer) { + init( indexName, indexedEntity, entityCreator, tenantConfigurer ); assertThat( searchMapping.countAbortedEvents( TENANT_1_ID ) ).isZero(); assertThat( searchMapping.countAbortedEvents( TENANT_2_ID ) ).isZero(); assertThat( searchMapping.countAbortedEvents( TENANT_3_ID ) ).isZero(); @@ -186,8 +194,11 @@ public void clearAllAbortedEvents() { assertThat( searchMapping.countAbortedEvents( TENANT_3_ID ) ).isZero(); } - @Test - public void reprocessAbortedEvents() { + @ParameterizedTest(name = "entity = {0}") + @MethodSource("params") + void reprocessAbortedEvents(String indexName, Class indexedEntity, + BiConsumer entityCreator, Consumer tenantConfigurer) { + init( indexName, indexedEntity, entityCreator, tenantConfigurer ); assertThat( searchMapping.countAbortedEvents( TENANT_1_ID ) ).isZero(); assertThat( searchMapping.countAbortedEvents( TENANT_2_ID ) ).isZero(); assertThat( searchMapping.countAbortedEvents( TENANT_3_ID ) ).isZero(); diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/schema/OutboxPollingCustomEntityMappingDatabaseColumnTypesIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/schema/OutboxPollingCustomEntityMappingDatabaseColumnTypesIT.java index 0d99f137e58..8b9ada8c0a8 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/schema/OutboxPollingCustomEntityMappingDatabaseColumnTypesIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/schema/OutboxPollingCustomEntityMappingDatabaseColumnTypesIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.schema; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.fail; import java.sql.Types; @@ -33,30 +33,30 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.event.impl.OutboxEvent; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class OutboxPollingCustomEntityMappingDatabaseColumnTypesIT { +class OutboxPollingCustomEntityMappingDatabaseColumnTypesIT { - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); private SessionFactory sessionFactory; @Test - public void test() { + void test() { backendMock.expectAnySchema( IndexedEntity.INDEX ); sessionFactory = ormSetupHelper.start() .withProperty( "hibernate.show_sql", true ) diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/schema/OutboxPollingCustomEntityMappingIT.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/schema/OutboxPollingCustomEntityMappingIT.java index d28b39d1ab4..829198fcbe8 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/schema/OutboxPollingCustomEntityMappingIT.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/schema/OutboxPollingCustomEntityMappingIT.java @@ -10,7 +10,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.awaitility.Awaitility.await; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.Arrays; @@ -42,15 +42,15 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.work.spi.PojoIndexingQueueEventPayload; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class OutboxPollingCustomEntityMappingIT { +class OutboxPollingCustomEntityMappingIT { private static final String CUSTOM_SCHEMA = "CUSTOM_SCHEMA"; private static final String ORIGINAL_OUTBOX_EVENT_TABLE_NAME = @@ -81,13 +81,13 @@ public class OutboxPollingCustomEntityMappingIT { }; } - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ) .coordinationStrategy( CoordinationStrategyExpectations.outboxPolling() ); @@ -96,7 +96,7 @@ public class OutboxPollingCustomEntityMappingIT { private final OutboxEventFilter eventFilter = new OutboxEventFilter(); @Test - public void wrongOutboxEventMapping() { + void wrongOutboxEventMapping() { assertThatThrownBy( () -> ormSetupHelper.start() .withProperty( "hibernate.search.coordination.outboxevent.entity.mapping", "" ) @@ -106,7 +106,7 @@ public void wrongOutboxEventMapping() { } @Test - public void wrongAgentMapping() { + void wrongAgentMapping() { assertThatThrownBy( () -> ormSetupHelper.start() .withProperty( "hibernate.search.coordination.agent.entity.mapping", "" ) @@ -116,7 +116,7 @@ public void wrongAgentMapping() { } @Test - public void validOutboxEventMapping() { + void validOutboxEventMapping() { KeysStatementInspector statementInspector = new KeysStatementInspector(); backendMock.expectAnySchema( IndexedEntity.INDEX ); @@ -146,7 +146,7 @@ public void validOutboxEventMapping() { } @Test - public void validAgentMapping() { + void validAgentMapping() { KeysStatementInspector statementInspector = new KeysStatementInspector(); backendMock.expectAnySchema( IndexedEntity.INDEX ); @@ -176,7 +176,7 @@ public void validAgentMapping() { } @Test - public void conflictingAgentMappingConfiguration() { + void conflictingAgentMappingConfiguration() { assertThatThrownBy( () -> ormSetupHelper.start() .withProperty( "hibernate.search.coordination.agent.entity.mapping", VALID_AGENT_EVENT_MAPPING ) .withProperty( "hibernate.search.coordination.entity.mapping.agent.table", "break_it_all" ) @@ -186,7 +186,7 @@ public void conflictingAgentMappingConfiguration() { } @Test - public void conflictingOutboxeventMappingConfiguration() { + void conflictingOutboxeventMappingConfiguration() { assertThatThrownBy( () -> ormSetupHelper.start() .withProperty( "hibernate.search.coordination.outboxevent.entity.mapping", VALID_OUTBOX_EVENT_MAPPING ) .withProperty( "hibernate.search.coordination.entity.mapping.outboxevent.table", "break_it_all" ) @@ -196,7 +196,7 @@ public void conflictingOutboxeventMappingConfiguration() { } @Test - public void validMappingWithCustomNames() { + void validMappingWithCustomNames() { KeysStatementInspector statementInspector = new KeysStatementInspector(); backendMock.expectAnySchema( IndexedEntity.INDEX ); @@ -227,7 +227,7 @@ public void validMappingWithCustomNames() { } @Test - public void validMappingWithCustomNamesAndSchema() { + void validMappingWithCustomNamesAndSchema() { KeysStatementInspector statementInspector = new KeysStatementInspector(); backendMock.expectAnySchema( IndexedEntity.INDEX ); @@ -245,10 +245,14 @@ public void validMappingWithCustomNamesAndSchema() { .setup( IndexedEntity.class ); backendMock.verifyExpectationsMet(); - assumeTrue( "This test only makes sense if the database supports schemas", - getNameQualifierSupport().supportsSchemas() ); - assumeTrue( "This test only makes sense if the dialect supports creating schemas", - getDialect().canCreateSchema() ); + assumeTrue( + getNameQualifierSupport().supportsSchemas(), + "This test only makes sense if the database supports schemas" + ); + assumeTrue( + getDialect().canCreateSchema(), + "This test only makes sense if the dialect supports creating schemas" + ); int id = 1; with( sessionFactory ).runInTransaction( session -> { @@ -283,7 +287,7 @@ public void validMappingWithCustomNamesAndSchema() { } @Test - public void validMappingWithCustomUuidGenerator() { + void validMappingWithCustomUuidGenerator() { KeysStatementInspector statementInspector = new KeysStatementInspector(); backendMock.expectAnySchema( IndexedEntity.INDEX ); @@ -328,7 +332,7 @@ public void validMappingWithCustomUuidGenerator() { } @Test - public void validMappingWithCustomUuidDataType() { + void validMappingWithCustomUuidDataType() { KeysStatementInspector statementInspector = new KeysStatementInspector(); backendMock.expectAnySchema( IndexedEntity.INDEX ); @@ -373,7 +377,7 @@ public void validMappingWithCustomUuidDataType() { } @Test - public void validMappingWithCustomFailingUuidGenerator() { + void validMappingWithCustomFailingUuidGenerator() { assertThatThrownBy( () -> ormSetupHelper.start() .withProperty( diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/testsupport/util/OutboxPollingOrmTestRunner.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/testsupport/util/OutboxPollingOrmTestRunner.java index 4aa023e3f39..6eb49689e00 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/testsupport/util/OutboxPollingOrmTestRunner.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/testsupport/util/OutboxPollingOrmTestRunner.java @@ -6,18 +6,21 @@ */ package org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util; -import org.junit.extensions.cpsuite.ClasspathSuite; -import org.junit.runner.RunWith; +import org.junit.platform.suite.api.IncludeClassNamePatterns; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; +import org.junit.platform.suite.api.SuiteDisplayName; /** * Helper for running specific Hibernate ORM integration tests with outbox-polling from the IDE. *

* Adapt the classpath filter as needed to run a single test or an entire test package. */ -@RunWith(ClasspathSuite.class) -@ClasspathSuite.ClassnameFilters({ - "org.hibernate.search.integrationtest.mapper.orm.automaticindexing.*" -}) +@Suite +@SuiteDisplayName("Lucene TCK tests Runner") +// Defines a "root" package, subpackages are included. Use Include/Exclude ClassNamePatterns annotations to limit the executed tests: +@SelectPackages("org.hibernate.search.integrationtest.mapper.orm.automaticindexing") +// Default class pattern does not include IT tests, hence we want to customize it a bit: +@IncludeClassNamePatterns({ ".*Test", ".*IT" }) public class OutboxPollingOrmTestRunner { - } diff --git a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/testsupport/util/PerSessionFactoryIndexingCountHelper.java b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/testsupport/util/PerSessionFactoryIndexingCountHelper.java index 3e2a95fd4fd..55a494dead5 100644 --- a/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/testsupport/util/PerSessionFactoryIndexingCountHelper.java +++ b/integrationtest/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/testsupport/util/PerSessionFactoryIndexingCountHelper.java @@ -32,7 +32,7 @@ import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.model.StubIndexSchemaDataNode; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.SimpleSessionFactoryBuilder; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; import org.assertj.core.api.AbstractIntegerAssert; import org.assertj.core.api.InstanceOfAssertFactories; diff --git a/integrationtest/mapper/orm-envers/src/test/java/org/hibernate/search/integrationtest/mapper/orm/envers/EnversIT.java b/integrationtest/mapper/orm-envers/src/test/java/org/hibernate/search/integrationtest/mapper/orm/envers/EnversIT.java index a8d2c667cbe..3f658ffe497 100644 --- a/integrationtest/mapper/orm-envers/src/test/java/org/hibernate/search/integrationtest/mapper/orm/envers/EnversIT.java +++ b/integrationtest/mapper/orm-envers/src/test/java/org/hibernate/search/integrationtest/mapper/orm/envers/EnversIT.java @@ -27,30 +27,30 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = { "HSEARCH-1293", "HSEARCH-3667" }) @PortedFromSearch5(original = "org.hibernate.search.test.envers.SearchAndEnversIntegrationTest") -public class EnversIT { +class EnversIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.NAME, b -> b .field( "text", String.class ) .objectField( "contained", b2 -> b2 @@ -67,7 +67,7 @@ public void setup() { } @Test - public void test() { + void test() { // Initial insert with( sessionFactory ).runInTransaction( session -> { IndexedEntity indexed = new IndexedEntity(); diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/EntityReaderComponentIT.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/EntityReaderComponentIT.java index caeb70c7d35..aa05663a4a8 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/EntityReaderComponentIT.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/EntityReaderComponentIT.java @@ -6,8 +6,7 @@ */ package org.hibernate.search.integrationtest.jakarta.batch.component; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -122,10 +121,10 @@ public void testReadItem_withoutBoundary() throws Exception { entityReader.open( null ); for ( Company expected : COMPANIES ) { Company actual = (Company) entityReader.readItem(); - assertEquals( expected.getName(), actual.getName() ); + assertThat( actual.getName() ).isEqualTo( expected.getName() ); } // no more item - assertNull( entityReader.readItem() ); + assertThat( entityReader.readItem() ).isNull(); } finally { entityReader.close(); diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/HibernateSearchPartitionMapperComponentIT.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/HibernateSearchPartitionMapperComponentIT.java index 373c8fa41d3..9012f24b084 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/HibernateSearchPartitionMapperComponentIT.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/HibernateSearchPartitionMapperComponentIT.java @@ -6,8 +6,7 @@ */ package org.hibernate.search.integrationtest.jakarta.batch.component; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -22,7 +21,6 @@ import org.hibernate.search.integrationtest.jakarta.batch.massindexing.entity.Person; import org.hibernate.search.integrationtest.jakarta.batch.util.BackendConfigurations; import org.hibernate.search.integrationtest.jakarta.batch.util.JobTestUtil; -import org.hibernate.search.integrationtest.jakarta.batch.util.PersistenceUnitTestUtil; import org.hibernate.search.jakarta.batch.core.massindexing.impl.JobContextData; import org.hibernate.search.jakarta.batch.core.massindexing.step.impl.HibernateSearchPartitionMapper; import org.hibernate.search.jakarta.batch.core.massindexing.util.impl.MassIndexingPartitionProperties; @@ -43,7 +41,6 @@ */ public class HibernateSearchPartitionMapperComponentIT { - private static final String PERSISTENCE_UNIT_NAME = PersistenceUnitTestUtil.getPersistenceUnitName(); private static final int COMP_ROWS = 3; private static final int PERS_ROWS = 8; @@ -128,12 +125,12 @@ public void testMapPartitions() throws Exception { * since the value of rowsPerPartition is lower than the static default for checkpoint interval. */ String checkpointInterval = p.getProperty( MassIndexingPartitionProperties.CHECKPOINT_INTERVAL ); - assertNotNull( checkpointInterval ); - assertEquals( "3", checkpointInterval ); + assertThat( checkpointInterval ).isNotNull(); + assertThat( checkpointInterval ).isEqualTo( "3" ); } // nbPartitions = rows / rowsPerPartition - assertEquals( 1, compPartitions ); // 3 / 3 => 1 partition - assertEquals( 3, persPartitions ); // 8 / 3 => 3 partitions + assertThat( compPartitions ).isEqualTo( 1 ); // 3 / 3 => 1 partition + assertThat( persPartitions ).isEqualTo( 3 ); // 8 / 3 => 3 partitions } } diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/ValidationUtilComponentIT.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/ValidationUtilComponentIT.java index c149525d97e..e161fff6788 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/ValidationUtilComponentIT.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/component/ValidationUtilComponentIT.java @@ -65,14 +65,16 @@ public void validateEntityTypes_whenContainingNonIndexedTypes() throws Exception + NotIndexed.class.getName() + ". Check whether they are annotated with '@Indexed'." ); } - @Test(expected = SearchException.class) + @Test public void validatePositive_valueIsNegative() throws Exception { - ValidationUtil.validatePositive( "MyParameter", -1 ); + assertThatThrownBy( () -> ValidationUtil.validatePositive( "MyParameter", -1 ) ) + .isInstanceOf( SearchException.class ); } - @Test(expected = SearchException.class) + @Test public void validatePositive_valueIsZero() throws Exception { - ValidationUtil.validatePositive( "MyParameter", 0 ); + assertThatThrownBy( () -> ValidationUtil.validatePositive( "MyParameter", 0 ) ) + .isInstanceOf( SearchException.class ); } @Test @@ -110,9 +112,10 @@ public void validateSessionClearInterval_equalToCheckpointInterval() { // ok } - @Test(expected = SearchException.class) + @Test public void validateSessionClearInterval_greaterThanCheckpointInterval() throws Exception { - ValidationUtil.validateSessionClearInterval( 101, 100 ); + assertThatThrownBy( () -> ValidationUtil.validateSessionClearInterval( 101, 100 ) ) + .isInstanceOf( SearchException.class ); } private static class NotIndexed { diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/BatchIndexingJobIT.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/BatchIndexingJobIT.java index 8280604776e..12e0d7a1066 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/BatchIndexingJobIT.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/BatchIndexingJobIT.java @@ -9,7 +9,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; import static org.hibernate.search.integrationtest.jakarta.batch.util.JobTestUtil.JOB_TIMEOUT_MS; -import static org.junit.Assert.assertEquals; import java.io.IOException; import java.lang.invoke.MethodHandles; @@ -56,7 +55,6 @@ * @author Mincong Huang */ public class BatchIndexingJobIT { - private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() ); protected static final int INSTANCES_PER_DATA_TEMPLATE = 100; @@ -125,9 +123,9 @@ public void simple() List companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); List people = JobTestUtil.findIndexedResults( emf, Person.class, "firstName", "Linus" ); List whos = JobTestUtil.findIndexedResults( emf, WhoAmI.class, "id", "id01" ); - assertEquals( 0, companies.size() ); - assertEquals( 0, people.size() ); - assertEquals( 0, whos.size() ); + assertThat( companies ).isEmpty(); + assertThat( people ).isEmpty(); + assertThat( whos ).isEmpty(); long executionId = jobOperator.start( MassIndexingJob.NAME, @@ -146,9 +144,9 @@ public void simple() companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); people = JobTestUtil.findIndexedResults( emf, Person.class, "firstName", "Linus" ); whos = JobTestUtil.findIndexedResults( emf, WhoAmI.class, "id", "id01" ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, companies.size() ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, people.size() ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, whos.size() ); + assertThat( companies ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); + assertThat( people ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); + assertThat( whos ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); } @Test @@ -158,9 +156,9 @@ public void simple_defaultCheckpointInterval() List companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); List people = JobTestUtil.findIndexedResults( emf, Person.class, "firstName", "Linus" ); List whos = JobTestUtil.findIndexedResults( emf, WhoAmI.class, "id", "id01" ); - assertEquals( 0, companies.size() ); - assertEquals( 0, people.size() ); - assertEquals( 0, whos.size() ); + assertThat( companies ).isEmpty(); + assertThat( people ).isEmpty(); + assertThat( whos ).isEmpty(); long executionId = jobOperator.start( MassIndexingJob.NAME, @@ -178,9 +176,9 @@ public void simple_defaultCheckpointInterval() companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); people = JobTestUtil.findIndexedResults( emf, Person.class, "firstName", "Linus" ); whos = JobTestUtil.findIndexedResults( emf, WhoAmI.class, "id", "id01" ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, companies.size() ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, people.size() ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, whos.size() ); + assertThat( companies ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); + assertThat( people ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); + assertThat( whos ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); } @Test @@ -213,9 +211,9 @@ public void indexedEmbeddedCollection() JobTestUtil.findIndexedResults( emf, CompanyGroup.class, "companies.name", "Red Hat" ); List groupsContainingMicrosoft = JobTestUtil.findIndexedResults( emf, CompanyGroup.class, "companies.name", "Microsoft" ); - assertEquals( 0, groupsContainingGoogle.size() ); - assertEquals( 0, groupsContainingRedHat.size() ); - assertEquals( 0, groupsContainingMicrosoft.size() ); + assertThat( groupsContainingGoogle ).isEmpty(); + assertThat( groupsContainingRedHat ).isEmpty(); + assertThat( groupsContainingMicrosoft ).isEmpty(); long executionId = jobOperator.start( MassIndexingJob.NAME, @@ -232,18 +230,18 @@ public void indexedEmbeddedCollection() groupsContainingGoogle = JobTestUtil.findIndexedResults( emf, CompanyGroup.class, "companies.name", "Google" ); groupsContainingRedHat = JobTestUtil.findIndexedResults( emf, CompanyGroup.class, "companies.name", "Red Hat" ); groupsContainingMicrosoft = JobTestUtil.findIndexedResults( emf, CompanyGroup.class, "companies.name", "Microsoft" ); - assertEquals( 2 * INSTANCES_PER_DATA_TEMPLATE, groupsContainingGoogle.size() ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, groupsContainingRedHat.size() ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, groupsContainingMicrosoft.size() ); + assertThat( groupsContainingGoogle ).hasSize( 2 * INSTANCES_PER_DATA_TEMPLATE ); + assertThat( groupsContainingRedHat ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); + assertThat( groupsContainingMicrosoft ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); } @Test public void purge() throws InterruptedException, IOException { int expectedCount = 10; - assertEquals( 0, JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ).isZero(); indexSomeCompanies( expectedCount ); - assertEquals( expectedCount, JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ).isEqualTo( expectedCount ); /* * Request a mass indexing with a filter matching nothing, @@ -260,16 +258,16 @@ public void purge() throws InterruptedException, IOException { JobExecution jobExecution = jobOperator.getJobExecution( executionId ); JobTestUtil.waitForTermination( jobOperator, jobExecution, JOB_TIMEOUT_MS ); - assertEquals( 0, JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ).isZero(); } @Test public void noPurge() throws InterruptedException, IOException { int expectedCount = 10; - assertEquals( 0, JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ).isZero(); indexSomeCompanies( expectedCount ); - assertEquals( expectedCount, JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ).isEqualTo( expectedCount ); /* * Request a mass indexing with a filter matching nothing, and requesting no purge at all, @@ -286,7 +284,7 @@ public void noPurge() throws InterruptedException, IOException { JobExecution jobExecution = jobOperator.getJobExecution( executionId ); JobTestUtil.waitForTermination( jobOperator, jobExecution, JOB_TIMEOUT_MS ); - assertEquals( expectedCount, JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ).isEqualTo( expectedCount ); } @Test @@ -295,9 +293,9 @@ public void hql() IOException { // searches before mass index, // expected no results for each search - assertEquals( 0, JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ).size() ); - assertEquals( 0, JobTestUtil.findIndexedResults( emf, Company.class, "name", "Red Hat" ).size() ); - assertEquals( 0, JobTestUtil.findIndexedResults( emf, Company.class, "name", "Microsoft" ).size() ); + assertThat( JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ) ).isEmpty(); + assertThat( JobTestUtil.findIndexedResults( emf, Company.class, "name", "Red Hat" ) ).isEmpty(); + assertThat( JobTestUtil.findIndexedResults( emf, Company.class, "name", "Microsoft" ) ).isEmpty(); long executionId = jobOperator.start( MassIndexingJob.NAME, @@ -310,11 +308,11 @@ public void hql() JobExecution jobExecution = jobOperator.getJobExecution( executionId ); JobTestUtil.waitForTermination( jobOperator, jobExecution, JOB_TIMEOUT_MS ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, - JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ).size() ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, - JobTestUtil.findIndexedResults( emf, Company.class, "name", "Red Hat" ).size() ); - assertEquals( 0, JobTestUtil.findIndexedResults( emf, Company.class, "name", "Microsoft" ).size() ); + assertThat( JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ) ) + .hasSize( INSTANCES_PER_DATA_TEMPLATE ); + assertThat( JobTestUtil.findIndexedResults( emf, Company.class, "name", "Red Hat" ) ) + .hasSize( INSTANCES_PER_DATA_TEMPLATE ); + assertThat( JobTestUtil.findIndexedResults( emf, Company.class, "name", "Microsoft" ) ).isEmpty(); } @Test @@ -323,7 +321,7 @@ public void hql_maxResults() IOException { // searches before mass index, // expected no results for each search - assertEquals( 0, JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ).isZero(); int maxResults = CHECKPOINT_INTERVAL + 1; @@ -339,7 +337,7 @@ public void hql_maxResults() JobExecution jobExecution = jobOperator.getJobExecution( executionId ); JobTestUtil.waitForTermination( jobOperator, jobExecution, JOB_TIMEOUT_MS ); - assertEquals( maxResults, JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, Company.class ) ).isEqualTo( maxResults ); } @Test @@ -349,9 +347,9 @@ public void partitioned() List companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); List people = JobTestUtil.findIndexedResults( emf, Person.class, "firstName", "Linus" ); List whos = JobTestUtil.findIndexedResults( emf, WhoAmI.class, "id", "id01" ); - assertEquals( 0, companies.size() ); - assertEquals( 0, people.size() ); - assertEquals( 0, whos.size() ); + assertThat( companies ).isEmpty(); + assertThat( people ).isEmpty(); + assertThat( whos ).isEmpty(); long executionId = jobOperator.start( MassIndexingJob.NAME, @@ -388,9 +386,9 @@ public void partitioned() companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); people = JobTestUtil.findIndexedResults( emf, Person.class, "firstName", "Linus" ); whos = JobTestUtil.findIndexedResults( emf, WhoAmI.class, "id", "id01" ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, companies.size() ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, people.size() ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, whos.size() ); + assertThat( companies ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); + assertThat( people ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); + assertThat( whos ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); } private void assertCompletion(long executionId) { @@ -398,7 +396,7 @@ private void assertCompletion(long executionId) { for ( StepExecution stepExecution : stepExecutions ) { BatchStatus batchStatus = stepExecution.getBatchStatus(); log.infof( "step %s executed.", stepExecution.getStepName() ); - assertEquals( BatchStatus.COMPLETED, batchStatus ); + assertThat( batchStatus ).isEqualTo( BatchStatus.COMPLETED ); } } @@ -410,7 +408,7 @@ private void assertProgress(long executionId, Class entityType, int progressV * Thus we check our own object. */ StepProgress progress = getMainStepProgress( executionId ); - assertEquals( Long.valueOf( progressValue ), progress.getEntityProgress().get( entityType.getName() ) ); + assertThat( progress.getEntityProgress() ).containsEntry( entityType.getName(), Long.valueOf( progressValue ) ); } private StepProgress getMainStepProgress(long executionId) { diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/EntityManagerFactoryRetrievalIT.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/EntityManagerFactoryRetrievalIT.java index 7afa6dc10aa..a7d463ead1b 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/EntityManagerFactoryRetrievalIT.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/EntityManagerFactoryRetrievalIT.java @@ -6,9 +6,9 @@ */ package org.hibernate.search.integrationtest.jakarta.batch.massindexing; +import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.integrationtest.jakarta.batch.util.JobTestUtil.JOB_TIMEOUT_MS; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.List; @@ -25,14 +25,14 @@ import org.hibernate.search.integrationtest.jakarta.batch.util.PersistenceUnitTestUtil; import org.hibernate.search.jakarta.batch.core.massindexing.MassIndexingJob; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * @author Mincong Huang */ -public class EntityManagerFactoryRetrievalIT { +class EntityManagerFactoryRetrievalIT { private static final String PERSISTENCE_UNIT_NAME = PersistenceUnitTestUtil.getPersistenceUnitName(); @@ -52,8 +52,8 @@ public class EntityManagerFactoryRetrievalIT { protected JobOperator jobOperator; protected EntityManagerFactory emf; - @Before - public void setup() { + @BeforeEach + void setup() { jobOperator = JobTestUtil.getAndCheckRuntime(); List companies = new ArrayList<>(); List people = new ArrayList<>(); @@ -81,8 +81,8 @@ public void setup() { } ); } - @After - public void shutdown() { + @AfterEach + void shutdown() { if ( emf != null ) { emf.close(); } @@ -93,9 +93,9 @@ protected String getPersistenceUnitName() { } @Test - public void defaultNamespace() throws Exception { + void defaultNamespace() throws Exception { List companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); - assertEquals( 0, companies.size() ); + assertThat( companies ).isEmpty(); long executionId = jobOperator.start( MassIndexingJob.NAME, @@ -109,13 +109,13 @@ public void defaultNamespace() throws Exception { JobTestUtil.waitForTermination( jobOperator, jobExecution, JOB_TIMEOUT_MS ); companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, companies.size() ); + assertThat( companies ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); } @Test - public void persistenceUnitNamespace() throws Exception { + void persistenceUnitNamespace() throws Exception { List companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); - assertEquals( 0, companies.size() ); + assertThat( companies ).isEmpty(); long executionId = jobOperator.start( MassIndexingJob.NAME, @@ -130,13 +130,13 @@ public void persistenceUnitNamespace() throws Exception { JobTestUtil.waitForTermination( jobOperator, jobExecution, JOB_TIMEOUT_MS ); companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, companies.size() ); + assertThat( companies ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); } @Test - public void sessionFactoryNamespace() throws Exception { + void sessionFactoryNamespace() throws Exception { List companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); - assertEquals( 0, companies.size() ); + assertThat( companies ).isEmpty(); long executionId = jobOperator.start( MassIndexingJob.NAME, @@ -151,7 +151,7 @@ public void sessionFactoryNamespace() throws Exception { JobTestUtil.waitForTermination( jobOperator, jobExecution, JOB_TIMEOUT_MS ); companies = JobTestUtil.findIndexedResults( emf, Company.class, "name", "Google" ); - assertEquals( INSTANCES_PER_DATA_TEMPLATE, companies.size() ); + assertThat( companies ).hasSize( INSTANCES_PER_DATA_TEMPLATE ); } } diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/RestartChunkIT.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/RestartChunkIT.java index be4dcfe5ee0..5559638fbe8 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/RestartChunkIT.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/massindexing/RestartChunkIT.java @@ -6,8 +6,8 @@ */ package org.hibernate.search.integrationtest.jakarta.batch.massindexing; +import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.integrationtest.jakarta.batch.util.JobTestUtil.JOB_TIMEOUT_MS; -import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.List; @@ -128,10 +128,10 @@ public void failureDuringNonFirstCheckpointBetweenTwoWrites_hql() throws Interru } private void doTest(String hql, long expectedTotal, long expectedGoogle) throws InterruptedException, IOException { - assertEquals( 0, JobTestUtil.nbDocumentsInIndex( emf, SimulatedFailureCompany.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, SimulatedFailureCompany.class ) ).isZero(); List google = JobTestUtil.findIndexedResults( emf, SimulatedFailureCompany.class, "name", "Google" ); - assertEquals( 0, google.size() ); + assertThat( google ).isEmpty(); // start the job MassIndexingJob.ParametersBuilder builder = MassIndexingJob.parameters() @@ -149,7 +149,7 @@ private void doTest(String hql, long expectedTotal, long expectedGoogle) throws JobExecution jobExec1 = jobOperator.getJobExecution( execId1 ); JobTestUtil.waitForTermination( jobOperator, jobExec1, JOB_TIMEOUT_MS ); // job will be stopped by the SimulatedFailure - assertEquals( BatchStatus.FAILED, getMainStepStatus( execId1 ) ); + assertThat( getMainStepStatus( execId1 ) ).isEqualTo( BatchStatus.FAILED ); // restart the job /* @@ -159,12 +159,12 @@ private void doTest(String hql, long expectedTotal, long expectedGoogle) throws long execId2 = jobOperator.restart( execId1, parameters ); JobExecution jobExec2 = jobOperator.getJobExecution( execId2 ); JobTestUtil.waitForTermination( jobOperator, jobExec2, JOB_TIMEOUT_MS ); - assertEquals( BatchStatus.COMPLETED, getMainStepStatus( execId2 ) ); + assertThat( getMainStepStatus( execId2 ) ).isEqualTo( BatchStatus.COMPLETED ); // search again - assertEquals( expectedTotal, JobTestUtil.nbDocumentsInIndex( emf, SimulatedFailureCompany.class ) ); + assertThat( JobTestUtil.nbDocumentsInIndex( emf, SimulatedFailureCompany.class ) ).isEqualTo( expectedTotal ); google = JobTestUtil.findIndexedResults( emf, SimulatedFailureCompany.class, "name", "google" ); - assertEquals( expectedGoogle, google.size() ); + assertThat( google ).hasSize( (int) expectedGoogle ); } private Object getMainStepStatus(long execId1) { diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/BackendConfigurations.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/BackendConfigurations.java index 9023bbef4b8..848803feeb8 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/BackendConfigurations.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/BackendConfigurations.java @@ -6,11 +6,11 @@ */ package org.hibernate.search.integrationtest.jakarta.batch.util; -import static org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration.BACKEND_TYPE; +import static org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration.BACKEND_TYPE; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchBackendConfiguration; import org.hibernate.search.util.impl.integrationtest.backend.lucene.LuceneBackendConfiguration; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; public final class BackendConfigurations { diff --git a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/PersistenceUnitTestUtil.java b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/PersistenceUnitTestUtil.java index 299dcaf22fc..f54dfa1505d 100644 --- a/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/PersistenceUnitTestUtil.java +++ b/integrationtest/mapper/orm-jakarta-batch/src/test/java/org/hibernate/search/integrationtest/jakarta/batch/util/PersistenceUnitTestUtil.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.jakarta.batch.util; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; /** * @author Yoann Rodiere diff --git a/integrationtest/mapper/orm-realbackend/pom.xml b/integrationtest/mapper/orm-realbackend/pom.xml index 8b09f9a6ec4..09a2b8f6dfd 100644 --- a/integrationtest/mapper/orm-realbackend/pom.xml +++ b/integrationtest/mapper/orm-realbackend/pom.xml @@ -89,8 +89,9 @@ lucene - org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.BackendTypeAutoDetectMultipleBackendTypesInClasspathIT org.hibernate.search.integrationtest.mapper.orm.realbackend.schema.management.ElasticsearchSchemaManagerExporterIT + org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.ElasticsearchBackendTypeAutoDetectMultipleBackendTypesInClasspathIT + org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.LuceneBackendTypeAutoDetectMultipleBackendTypesInClasspathIT @@ -109,8 +110,9 @@ elasticsearch - org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.BackendTypeAutoDetectMultipleBackendTypesInClasspathIT org.hibernate.search.integrationtest.mapper.orm.realbackend.schema.management.LuceneSchemaManagerExporterIT + org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.ElasticsearchBackendTypeAutoDetectMultipleBackendTypesInClasspathIT + org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.LuceneBackendTypeAutoDetectMultipleBackendTypesInClasspathIT @@ -123,7 +125,8 @@ ${test.multiplebackends.skip} ${surefire.reportNameSuffix}-multiplebackends - org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.BackendTypeAutoDetectMultipleBackendTypesInClasspathIT + org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.ElasticsearchBackendTypeAutoDetectMultipleBackendTypesInClasspathIT + org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap.LuceneBackendTypeAutoDetectMultipleBackendTypesInClasspathIT diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/AbstractBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java similarity index 71% rename from integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java rename to integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/AbstractBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java index d7ee9b929d2..66ec965d87d 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/AbstractBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java @@ -16,46 +16,32 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchBackendConfiguration; -import org.hibernate.search.util.impl.integrationtest.backend.lucene.LuceneBackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Checks that Hibernate Search will fail to auto-detect the backend type and offer suggestions * if there are multiple backend types in the classpath. * Also checks that setting the property "hibernate.search.backend.type" will solve the problem. */ -@RunWith(Parameterized.class) -public class BackendTypeAutoDetectMultipleBackendTypesInClasspathIT { - - @Parameterized.Parameters(name = "{1}") - public static Object[][] params() { - return new Object[][] { - { new LuceneBackendConfiguration(), "lucene" }, - { new ElasticsearchBackendConfiguration(), "elasticsearch" } - }; - } - - @Rule - public OrmSetupHelper ormSetupHelper; - - private final String expectedBackendType; +public abstract class AbstractBackendTypeAutoDetectMultipleBackendTypesInClasspathIT { - public BackendTypeAutoDetectMultipleBackendTypesInClasspathIT(BackendConfiguration backendConfiguration, - String expectedBackendType) { - this.ormSetupHelper = OrmSetupHelper.withSingleBackend( backendConfiguration ); + protected AbstractBackendTypeAutoDetectMultipleBackendTypesInClasspathIT(String expectedBackendType, + BackendConfiguration backendConfiguration) { this.expectedBackendType = expectedBackendType; + this.ormSetupHelper = OrmSetupHelper.withSingleBackend( backendConfiguration ); } + private final String expectedBackendType; + @RegisterExtension + private final OrmSetupHelper ormSetupHelper; + @Test - public void backendType_notSet() { + void backendType_notSet() { assertThatThrownBy( () -> ormSetupHelper.start() .withBackendProperty( "type", null ) .setup( IndexedEntity.class ) ) @@ -70,7 +56,7 @@ public void backendType_notSet() { } @Test - public void backendType_set() { + void backendType_set() { SessionFactory sessionFactory = ormSetupHelper.start() .withBackendProperty( "type", expectedBackendType ) .setup( IndexedEntity.class ); diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BackendTypeAutoDetectSingleBackendTypeInClasspathIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BackendTypeAutoDetectSingleBackendTypeInClasspathIT.java index aa42b566aad..c653c4db85e 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BackendTypeAutoDetectSingleBackendTypeInClasspathIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BackendTypeAutoDetectSingleBackendTypeInClasspathIT.java @@ -7,8 +7,8 @@ package org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap; import static org.assertj.core.api.Assertions.assertThat; -import static org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration.BACKEND_TYPE; -import static org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration.IS_IDE; +import static org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration.BACKEND_TYPE; +import static org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration.IS_IDE; import jakarta.persistence.Entity; import jakarta.persistence.Id; @@ -19,20 +19,20 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Checks that Hibernate Search will auto-detect the backend type when the property "hibernate.search.backend.type" is not set * and there is only one backend in the classpath. */ -public class BackendTypeAutoDetectSingleBackendTypeInClasspathIT { +class BackendTypeAutoDetectSingleBackendTypeInClasspathIT { - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); @Test - public void backendType_autoDetect() { + void backendType_autoDetect() { if ( IS_IDE ) { throw new IllegalStateException( "Tests seem to be running from an IDE." + " This test cannot run from the IDE" diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BeanResolutionIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BeanResolutionIT.java index 3634cc142c8..5fdfbb50d6b 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BeanResolutionIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/BeanResolutionIT.java @@ -35,22 +35,22 @@ import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class BeanResolutionIT { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class BeanResolutionIT { - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private BeanContainer beanContainerMock; @@ -62,7 +62,7 @@ public class BeanResolutionIT { */ @Test @TestForIssue(jiraKey = "HSEARCH-4096") - public void noExplicitBean_noCallToBeanContainer() { + void noExplicitBean_noCallToBeanContainer() { setupHelper.start() .withProperty( AvailableSettings.BEAN_CONTAINER, beanContainerMock ) .setup( IndexedEntity.class ); @@ -73,7 +73,7 @@ public void noExplicitBean_noCallToBeanContainer() { @Test @TestForIssue(jiraKey = "HSEARCH-4096") - public void explicitBean_callToBeanContainer() { + void explicitBean_callToBeanContainer() { when( beanContainerMock .getBean( eq( "myConfigurer" ), eq( HibernateOrmSearchMappingConfigurer.class ), any(), any() ) ) .thenReturn( new StubContainedBean<>( new HibernateOrmSearchMappingConfigurer() { diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/ElasticsearchBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/ElasticsearchBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java new file mode 100644 index 00000000000..f2207113f15 --- /dev/null +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/ElasticsearchBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java @@ -0,0 +1,22 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap; + +import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchBackendConfiguration; + +/** + * Checks that Hibernate Search will fail to auto-detect the backend type and offer suggestions + * if there are multiple backend types in the classpath. + * Also checks that setting the property "hibernate.search.backend.type" will solve the problem. + */ +class ElasticsearchBackendTypeAutoDetectMultipleBackendTypesInClasspathIT + extends + AbstractBackendTypeAutoDetectMultipleBackendTypesInClasspathIT { + protected ElasticsearchBackendTypeAutoDetectMultipleBackendTypesInClasspathIT() { + super( "elasticsearch", new ElasticsearchBackendConfiguration() ); + } +} diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/LuceneBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/LuceneBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java new file mode 100644 index 00000000000..c1a18925665 --- /dev/null +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/bootstrap/LuceneBackendTypeAutoDetectMultipleBackendTypesInClasspathIT.java @@ -0,0 +1,21 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.search.integrationtest.mapper.orm.realbackend.bootstrap; + +import org.hibernate.search.util.impl.integrationtest.backend.lucene.LuceneBackendConfiguration; + +/** + * Checks that Hibernate Search will fail to auto-detect the backend type and offer suggestions + * if there are multiple backend types in the classpath. + * Also checks that setting the property "hibernate.search.backend.type" will solve the problem. + */ +class LuceneBackendTypeAutoDetectMultipleBackendTypesInClasspathIT + extends AbstractBackendTypeAutoDetectMultipleBackendTypesInClasspathIT { + protected LuceneBackendTypeAutoDetectMultipleBackendTypesInClasspathIT() { + super( "lucene", new LuceneBackendConfiguration() ); + } +} diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/limitations/ConcurrentEmbeddedUpdateLimitationIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/limitations/ConcurrentEmbeddedUpdateLimitationIT.java index 80eab33e56e..5e1b7a6b26c 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/limitations/ConcurrentEmbeddedUpdateLimitationIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/limitations/ConcurrentEmbeddedUpdateLimitationIT.java @@ -40,8 +40,8 @@ import org.hibernate.search.util.common.impl.SuppressingCloser; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.awaitility.Awaitility; import org.awaitility.core.ThrowingRunnable; @@ -49,16 +49,16 @@ /** * See "limitations-parallel-embedded-update" in the documentation. */ -public class ConcurrentEmbeddedUpdateLimitationIT { +class ConcurrentEmbeddedUpdateLimitationIT { - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private SessionFactory sessionFactory; private boolean synchronizationAsync; @Test - public void indexingStrategySession() throws Throwable { + void indexingStrategySession() throws Throwable { synchronizationAsync = false; sessionFactory = setupHelper.start() // This is absolutely necessary to avoid false positives in this test @@ -85,7 +85,7 @@ public void indexingStrategySession() throws Throwable { } @Test - public void indexingStrategyOutbox() throws Throwable { + void indexingStrategyOutbox() throws Throwable { synchronizationAsync = true; sessionFactory = setupHelper.start() .withProperty( "hibernate.search.coordination.strategy", "outbox-polling" ) diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/massindexing/MassIndexingManualSchemaManagementIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/massindexing/MassIndexingManualSchemaManagementIT.java index 3dcb76a92cd..793e77576a6 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/massindexing/MassIndexingManualSchemaManagementIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/massindexing/MassIndexingManualSchemaManagementIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.orm.realbackend.massindexing; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Fail.fail; import static org.hibernate.search.integrationtest.mapper.orm.realbackend.util.BookCreatorUtils.prepareBooks; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; @@ -20,12 +20,12 @@ import org.hibernate.search.mapper.orm.massindexing.MassIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MassIndexingManualSchemaManagementIT { +class MassIndexingManualSchemaManagementIT { private static final int NUMBER_OF_BOOKS = 200; private static final int MASS_INDEXING_MONITOR_LOG_PERIOD = 50; // This is the default in the implementation, do not change this value @@ -44,13 +44,13 @@ private static void checkInvariants() { } } - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void before() { + @BeforeEach + void before() { entityManagerFactory = setupHelper.start() .withProperty( "hibernate.search.indexing.listeners.enabled", false ) .withProperty( "hibernate.search.schema_management.strategy", "none" ) @@ -60,8 +60,8 @@ public void before() { cleanup(); } - @After - public void cleanup() { + @AfterEach + void cleanup() { // Necessary to keep the server (ES) or filesystem (Lucene) clean after the tests, // because the schema management strategy is "none" with( entityManagerFactory ) @@ -70,7 +70,7 @@ public void cleanup() { } @Test - public void testMassIndexingWithAutomaticDropAndCreate() { + void testMassIndexingWithAutomaticDropAndCreate() { // The index doesn't exist initially, since we delete it in "cleanup()" the schema management strategy is "none" with( entityManagerFactory ).runInTransaction( entityManager -> { MassIndexer indexer = Search.session( entityManager ).massIndexer() @@ -88,7 +88,7 @@ public void testMassIndexingWithAutomaticDropAndCreate() { } @Test - public void testMassIndexingWithManualDropAndCreate() { + void testMassIndexingWithManualDropAndCreate() { with( entityManagerFactory ).runInTransaction( entityManager -> { // The index doesn't exist initially, since the schema management strategy is "none" Search.session( entityManager ).schemaManager().dropAndCreate(); diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/massindexing/MassIndexingMonitorIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/massindexing/MassIndexingMonitorIT.java index 26dcce38948..f659ee5f06b 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/massindexing/MassIndexingMonitorIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/massindexing/MassIndexingMonitorIT.java @@ -19,15 +19,15 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.massindexing.MassIndexer; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; -public class MassIndexingMonitorIT { +class MassIndexingMonitorIT { private static final int NUMBER_OF_BOOKS = 200; private static final int MASS_INDEXING_MONITOR_LOG_PERIOD = 50; // This is the default in the implementation, do not change this value @@ -46,16 +46,16 @@ private static void checkInvariants() { } } - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void before() { + @BeforeEach + void before() { entityManagerFactory = setupHelper.start() .withProperty( "hibernate.search.indexing.listeners.enabled", false ) .setup( Book.class ); @@ -64,7 +64,7 @@ public void before() { } @Test - public void testMassIndexingMonitor() { + void testMassIndexingMonitor() { with( entityManagerFactory ).runInTransaction( entityManager -> { assertThat( BookCreatorUtils.documentsCount( entityManagerFactory ) ).isZero(); diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/multitenant/RealBackendDatabaseMultitenancyIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/multitenant/RealBackendDatabaseMultitenancyIT.java index aebaecb1e43..98d0ca10b8e 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/multitenant/RealBackendDatabaseMultitenancyIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/multitenant/RealBackendDatabaseMultitenancyIT.java @@ -26,23 +26,23 @@ import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.AssertionAndAssumptionViolationFallThrough; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class RealBackendDatabaseMultitenancyIT { +class RealBackendDatabaseMultitenancyIT { public static final String TENANT_ID_1 = "TENANT 1"; public static final String TENANT_ID_2 = "TENANT 2"; public static final String TENANT_TEXT_1 = "I'm in the TENANT 1"; public static final String TENANT_TEXT_2 = "I'm in the TENANT 2"; - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private SessionFactory sessionFactory; @Test - public void multiTenancyStrategy_discriminator() { + void multiTenancyStrategy_discriminator() { sessionFactory = setupHelper.start() .withProperty( "hibernate.search.backend.multi_tenancy.strategy", "discriminator" ) .withProperty( "hibernate.search.indexing.plan.synchronization.strategy", "sync" ) @@ -53,7 +53,7 @@ public void multiTenancyStrategy_discriminator() { } @Test - public void multiTenancyStrategy_enabledByMapping() { + void multiTenancyStrategy_enabledByMapping() { sessionFactory = setupHelper.start() .withProperty( "hibernate.search.indexing.plan.synchronization.strategy", "sync" ) .tenants( TENANT_ID_1, TENANT_ID_2 ) @@ -63,7 +63,7 @@ public void multiTenancyStrategy_enabledByMapping() { } @Test - public void multiTenancyStrategy_none() { + void multiTenancyStrategy_none() { assertThatThrownBy( () -> setupHelper.start() .withProperty( "hibernate.search.backend.multi_tenancy.strategy", "none" ) .tenants( TENANT_ID_1, TENANT_ID_2 ) diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/routing/RoutingBridgeConditionalIndexingIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/routing/RoutingBridgeConditionalIndexingIT.java index 290c139b088..1003c84c412 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/routing/RoutingBridgeConditionalIndexingIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/routing/RoutingBridgeConditionalIndexingIT.java @@ -31,23 +31,23 @@ import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategyNames; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test that defining a routing bridge that generates (mutable) routing keys works as expected * with a full setup (real mapper + real backend). */ -public class RoutingBridgeConditionalIndexingIT { +class RoutingBridgeConditionalIndexingIT { - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.INDEXING_PLAN_SYNCHRONIZATION_STRATEGY, IndexingPlanSynchronizationStrategyNames.READ_SYNC ) @@ -55,7 +55,7 @@ public void setup() { } @Test - public void testLifecycle() { + void testLifecycle() { assertThat( searchAllIds() ).isEmpty(); with( entityManagerFactory ).runInTransaction( entityManager -> { diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/routing/RoutingBridgeRoutingKeyIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/routing/RoutingBridgeRoutingKeyIT.java index dcdae06ae06..4cc1f6f2274 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/routing/RoutingBridgeRoutingKeyIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/routing/RoutingBridgeRoutingKeyIT.java @@ -30,27 +30,27 @@ import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategyNames; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test that defining a routing bridge that generates (mutable) routing keys works as expected * with a full setup (real mapper + real backend). */ -public class RoutingBridgeRoutingKeyIT { +class RoutingBridgeRoutingKeyIT { // Use high enough shard count that it's unlikely that our two routing keys end up in the same shard private static final int SHARD_COUNT = 64; - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.hashBasedSharding( SHARD_COUNT ) ); private EntityManagerFactory entityManagerFactory; - @Before - public void setup() { + @BeforeEach + void setup() { entityManagerFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.INDEXING_PLAN_SYNCHRONIZATION_STRATEGY, IndexingPlanSynchronizationStrategyNames.READ_SYNC ) @@ -62,7 +62,7 @@ public void setup() { } @Test - public void testLifecycle() { + void testLifecycle() { assertThat( searchIdsByRoutingKey( Genre.SCIENCE_FICTION ) ).isEmpty(); assertThat( searchIdsByRoutingKey( Genre.CRIME_FICTION ) ).isEmpty(); diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java index 3f891bbae93..d14614d5854 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java @@ -29,15 +29,15 @@ import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; -public class ElasticsearchSchemaManagerExporterIT { +class ElasticsearchSchemaManagerExporterIT { - @Rule - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); - @Rule + @TempDir + public Path temporaryFolder; + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withMultipleBackends( BackendConfigurations.simple(), Map.of( Article.BACKEND_NAME, BackendConfigurations.simple() ) @@ -46,7 +46,7 @@ public class ElasticsearchSchemaManagerExporterIT { private EntityManagerFactory entityManagerFactory; @Test - public void elasticsearch() throws IOException { + void elasticsearch() throws IOException { assumeFalse( "Older versions of Elasticsearch would not match the mappings", isActualVersion( @@ -64,7 +64,7 @@ public void elasticsearch() throws IOException { .withBackendProperty( Article.BACKEND_NAME, ElasticsearchBackendSettings.VERSION, version ) .setup( Book.class, Article.class ); - Path directory = temporaryFolder.newFolder().toPath(); + Path directory = temporaryFolder; Search.mapping( entityManagerFactory ).scope( Object.class ).schemaManager().exportExpectedSchema( directory ); assertJsonEqualsIgnoringUnknownFields( diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/LuceneSchemaManagerExporterIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/LuceneSchemaManagerExporterIT.java index 413f8809bb5..5c7041a56ff 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/LuceneSchemaManagerExporterIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/schema/management/LuceneSchemaManagerExporterIT.java @@ -23,15 +23,15 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; -public class LuceneSchemaManagerExporterIT { +class LuceneSchemaManagerExporterIT { - @Rule - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); - @Rule + @TempDir + public Path temporaryFolder; + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withMultipleBackends( BackendConfigurations.simple(), Map.of( Article.BACKEND_NAME, BackendConfigurations.simple() ) @@ -40,10 +40,10 @@ public class LuceneSchemaManagerExporterIT { private EntityManagerFactory entityManagerFactory; @Test - public void lucene() throws IOException { + void lucene() throws IOException { entityManagerFactory = setupHelper.start().setup( Book.class, Article.class ); - Path directory = temporaryFolder.newFolder().toPath(); + Path directory = temporaryFolder; Search.mapping( entityManagerFactory ).scope( Object.class ).schemaManager().exportExpectedSchema( directory ); String bookIndex = readString( diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/sync/OutOfSyncIndexIT.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/sync/OutOfSyncIndexIT.java index 6454c586aa2..d950a54f288 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/sync/OutOfSyncIndexIT.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/sync/OutOfSyncIndexIT.java @@ -22,24 +22,24 @@ import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test behavior when the index becomes out of sync with the database. */ -public class OutOfSyncIndexIT { +class OutOfSyncIndexIT { private static final int NUMBER_OF_BOOKS = 8; - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() ); private EntityManagerFactory entityManagerFactory; - @Before - public void before() { + @BeforeEach + void before() { entityManagerFactory = setupHelper.start() .withProperty( HibernateOrmMapperSettings.INDEXING_PLAN_SYNCHRONIZATION_STRATEGY, IndexingPlanSynchronizationStrategyNames.READ_SYNC ) @@ -50,7 +50,7 @@ public void before() { @Test @TestForIssue(jiraKey = "HSEARCH-3349") - public void search_skipDeletedEntitiesInHits() { + void search_skipDeletedEntitiesInHits() { // Check that document counts are identical int entityCount = entityCount(); int indexedEntityCount = BookCreatorUtils.documentsCount( entityManagerFactory ).intValue(); diff --git a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/testsupport/BackendConfigurations.java b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/testsupport/BackendConfigurations.java index c6130dbeaf2..9344e697ec5 100644 --- a/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/testsupport/BackendConfigurations.java +++ b/integrationtest/mapper/orm-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/orm/realbackend/testsupport/BackendConfigurations.java @@ -6,15 +6,15 @@ */ package org.hibernate.search.integrationtest.mapper.orm.realbackend.testsupport; -import static org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration.BACKEND_TYPE; +import static org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration.BACKEND_TYPE; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchBackendConfiguration; import org.hibernate.search.util.impl.integrationtest.backend.lucene.LuceneBackendConfiguration; import org.hibernate.search.util.impl.integrationtest.common.TestConfigurationProvider; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; -import org.hibernate.search.util.impl.integrationtest.common.rule.MappingSetupHelper; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.MappingSetupHelper; public class BackendConfigurations { diff --git a/integrationtest/mapper/orm-spring-uberjar/application/src/test/java/org/hibernate/search/integrationtest/spring/repackaged/application/NonRepackagedApplicationIT.java b/integrationtest/mapper/orm-spring-uberjar/application/src/test/java/org/hibernate/search/integrationtest/spring/repackaged/application/NonRepackagedApplicationIT.java index fa2a1705c1c..551a7704347 100644 --- a/integrationtest/mapper/orm-spring-uberjar/application/src/test/java/org/hibernate/search/integrationtest/spring/repackaged/application/NonRepackagedApplicationIT.java +++ b/integrationtest/mapper/orm-spring-uberjar/application/src/test/java/org/hibernate/search/integrationtest/spring/repackaged/application/NonRepackagedApplicationIT.java @@ -6,27 +6,24 @@ */ package org.hibernate.search.integrationtest.spring.repackaged.application; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; /** * This test runs in the failsafe classloader which gets classes * directly from the project build directory, * so it doesn't use the repackaged JAR. */ -@RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class NonRepackagedApplicationIT { +class NonRepackagedApplicationIT { @Autowired private SmokeTestingBean smokeTestingBean; @Test - public void smokeTest() { + void smokeTest() { smokeTestingBean.smokeTest(); } diff --git a/integrationtest/mapper/orm-spring-uberjar/application/src/test/java/org/hibernate/search/integrationtest/spring/repackaged/application/RepackagedApplicationIT.java b/integrationtest/mapper/orm-spring-uberjar/application/src/test/java/org/hibernate/search/integrationtest/spring/repackaged/application/RepackagedApplicationIT.java index 65b711588d2..2e6efcfae8c 100644 --- a/integrationtest/mapper/orm-spring-uberjar/application/src/test/java/org/hibernate/search/integrationtest/spring/repackaged/application/RepackagedApplicationIT.java +++ b/integrationtest/mapper/orm-spring-uberjar/application/src/test/java/org/hibernate/search/integrationtest/spring/repackaged/application/RepackagedApplicationIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.spring.repackaged.application; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import java.net.URL; import java.net.URLClassLoader; @@ -19,8 +19,8 @@ import org.hibernate.search.util.common.jar.impl.JandexUtils; import org.hibernate.search.util.impl.test.SystemHelper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; @@ -36,12 +36,12 @@ * it manipulates the repackaged JAR * to inspect it and run it in a separate JVM. */ -public class RepackagedApplicationIT { +class RepackagedApplicationIT { private String javaLauncherCommand; private Path repackedJarPath; - @Before - public void init() { + @BeforeEach + void init() { javaLauncherCommand = System.getProperty( "test.launcher-command" ); String repackedJarPathString = System.getProperty( "test.repackaged-jar-path" ); repackedJarPath = repackedJarPathString == null ? null : Paths.get( repackedJarPathString ); @@ -59,7 +59,7 @@ public void init() { * Test makes sure that the (repackaged) application behaves as expected on the current JDK. */ @Test - public void smokeTest() throws Exception { + void smokeTest() throws Exception { Process process = SystemHelper.runCommandWithInheritedIO( javaLauncherCommand, "-jar", repackedJarPath.toString() ); assertThat( process.exitValue() ) .as( "Starting the repackaged application should succeed" ) @@ -71,7 +71,7 @@ public void smokeTest() throws Exception { * We try to create index and then see that that index has the info we need e.g. projection/entity classes etc. */ @Test - public void canReadJar() throws Exception { + void canReadJar() throws Exception { try ( JarFile outerJar = new JarFile( repackedJarPath.toFile() ) ) { for ( JarEntry jarEntry : outerJar ) { if ( jarEntry.getName().contains( "hibernate-search-integrationtest-spring-repackaged-model" ) ) { diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/beanresolution/SpringBeanResolutionIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/beanresolution/SpringBeanResolutionIT.java index 0e102b18914..4e844460f73 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/beanresolution/SpringBeanResolutionIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/beanresolution/SpringBeanResolutionIT.java @@ -24,15 +24,15 @@ import org.hibernate.search.engine.environment.bean.BeanHolder; import org.hibernate.search.engine.environment.bean.BeanReference; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; import org.springframework.beans.factory.annotation.Autowired; @@ -60,7 +60,7 @@ * exactly as many times as expected. */ @TestForIssue(jiraKey = { "HSEARCH-1316", "HSEARCH-3171" }) -public class SpringBeanResolutionIT { +class SpringBeanResolutionIT { @Configuration @EnableAutoConfiguration @@ -84,17 +84,17 @@ public void initBackendMappingHandle(ApplicationReadyEvent event) { } } - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); @Test - public void singleton_byType() { + void singleton_byType() { doTest( ExpectedScope.SINGLETON, UnnamedSingletonBean.KEYS, BeanReference.of( UnnamedSingletonBean.class ) @@ -102,7 +102,7 @@ public void singleton_byType() { } @Test - public void singleton_byName() { + void singleton_byName() { doTest( ExpectedScope.SINGLETON, NamedSingletonBean.KEYS, BeanReference.of( InterfaceDefinedByMapper.class, NamedSingletonBean.NAME ) @@ -110,7 +110,7 @@ public void singleton_byName() { } @Test - public void prototype_byType() { + void prototype_byType() { doTest( ExpectedScope.PROTOTYPE, UnnamedPrototypeBean.KEYS, BeanReference.of( UnnamedPrototypeBean.class ) @@ -118,7 +118,7 @@ public void prototype_byType() { } @Test - public void prototype_byName() { + void prototype_byName() { doTest( ExpectedScope.PROTOTYPE, NamedPrototypeBean.KEYS, BeanReference.of( InterfaceDefinedByMapper.class, NamedPrototypeBean.NAME ) diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringIT.java index 55d114f7163..bb05ec606eb 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringIT.java @@ -15,30 +15,30 @@ import org.hibernate.search.integrationtest.spring.jta.dao.SnertDAO; import org.hibernate.search.integrationtest.spring.jta.entity.Snert; import org.hibernate.search.mapper.orm.session.impl.HibernateOrmSearchSessionHolder; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringApplicationConfiguration.class) @ActiveProfiles("jta") @PortedFromSearch5(original = "org.hibernate.search.test.integration.spring.jta.JtaAndSpringIT") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class JtaAndSpringIT { +class JtaAndSpringIT { @Autowired - @Rule + @RegisterExtension public BackendMock backendMock; @Autowired @@ -47,20 +47,20 @@ public class JtaAndSpringIT { @Autowired private EntityManagerFactory entityManagerFactory; - @Before - public void checkJta() { + @BeforeEach + void checkJta() { assertThat( entityManagerFactory.unwrap( SessionFactoryImplementor.class ) .getServiceRegistry().getService( TransactionCoordinatorBuilder.class ) ) .returns( true, TransactionCoordinatorBuilder::isJta ); } - @After - public void checkNoMemoryLeak() { + @AfterEach + void checkNoMemoryLeak() { assertThat( HibernateOrmSearchSessionHolder.staticMapSize() ).isZero(); } @Test - public void test() { + void test() { Snert snert = new Snert(); snert.setId( 1L ); snert.setName( "dave" ); diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringMoreComplexIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringMoreComplexIT.java index d1d31e1bdda..8d9dbc02d17 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringMoreComplexIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringMoreComplexIT.java @@ -17,30 +17,30 @@ import org.hibernate.search.integrationtest.spring.jta.entity.Doughnut; import org.hibernate.search.integrationtest.spring.jta.entity.Muffin; import org.hibernate.search.mapper.orm.session.impl.HibernateOrmSearchSessionHolder; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringApplicationConfiguration.class) @ActiveProfiles("jta") @PortedFromSearch5(original = "org.hibernate.search.test.integration.spring.jta.JtaAndSpringMoreComplexIT") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class JtaAndSpringMoreComplexIT { +class JtaAndSpringMoreComplexIT { @Autowired - @Rule + @RegisterExtension public BackendMock backendMock; @Autowired @@ -49,20 +49,20 @@ public class JtaAndSpringMoreComplexIT { @Autowired private EntityManagerFactory entityManagerFactory; - @Before - public void checkJta() { + @BeforeEach + void checkJta() { assertThat( entityManagerFactory.unwrap( SessionFactoryImplementor.class ) .getServiceRegistry().getService( TransactionCoordinatorBuilder.class ) ) .returns( true, TransactionCoordinatorBuilder::isJta ); } - @After - public void checkNoMemoryLeak() { + @AfterEach + void checkNoMemoryLeak() { assertThat( HibernateOrmSearchSessionHolder.staticMapSize() ).isZero(); } @Test - public void testMuffins() { + void testMuffins() { Box box = new Box(); box.setContainerId( 1L ); box.setColor( "red-and-white" ); @@ -99,7 +99,7 @@ public void testMuffins() { } @Test - public void testDoughnuts() { + void testDoughnuts() { Box box = new Box(); box.setContainerId( 2L ); box.setColor( "red-and-white" ); diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxApplicationConfiguration.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxApplicationConfiguration.java index 4c9a90fbbde..470816a41d8 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxApplicationConfiguration.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxApplicationConfiguration.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.spring.jta; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; public class JtaAndSpringOutboxApplicationConfiguration extends JtaAndSpringApplicationConfiguration { diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxIT.java index cebc2409f5c..aaea9a49a62 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/JtaAndSpringOutboxIT.java @@ -15,28 +15,28 @@ import org.hibernate.search.integrationtest.spring.jta.dao.SnertDAO; import org.hibernate.search.integrationtest.spring.jta.entity.Snert; import org.hibernate.search.mapper.orm.session.impl.HibernateOrmSearchSessionHolder; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringOutboxApplicationConfiguration.class) @ActiveProfiles({ "jta", "outbox" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class JtaAndSpringOutboxIT { +class JtaAndSpringOutboxIT { @Autowired - @Rule + @RegisterExtension public BackendMock backendMock; @Autowired @@ -45,20 +45,20 @@ public class JtaAndSpringOutboxIT { @Autowired private EntityManagerFactory entityManagerFactory; - @Before - public void checkJta() { + @BeforeEach + void checkJta() { assertThat( entityManagerFactory.unwrap( SessionFactoryImplementor.class ) .getServiceRegistry().getService( TransactionCoordinatorBuilder.class ) ) .returns( true, TransactionCoordinatorBuilder::isJta ); } - @After - public void checkNoMemoryLeak() { + @AfterEach + void checkNoMemoryLeak() { assertThat( HibernateOrmSearchSessionHolder.staticMapSize() ).isZero(); } @Test - public void test() { + void test() { Snert snert = new Snert(); snert.setId( 1L ); snert.setName( "dave" ); diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java index 220567381a8..282f78d88f1 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/RaisedTimeoutJtaAndSpringOutboxIT.java @@ -15,12 +15,12 @@ import org.hibernate.search.integrationtest.spring.jta.JtaAndSpringOutboxApplicationConfiguration; import org.hibernate.search.integrationtest.spring.jta.dao.SnertDAO; import org.hibernate.search.integrationtest.spring.jta.entity.Snert; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import com.atomikos.icatch.jta.TransactionManagerImp; @@ -28,16 +28,16 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringOutboxApplicationConfiguration.class) @ActiveProfiles({ "jta", "outbox", "transaction-timeout", "raised-timeout" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class RaisedTimeoutJtaAndSpringOutboxIT { +class RaisedTimeoutJtaAndSpringOutboxIT { @Autowired - @Rule + @RegisterExtension public BackendMock backendMock; @Autowired @@ -46,8 +46,8 @@ public class RaisedTimeoutJtaAndSpringOutboxIT { @Autowired private EntityManagerFactory entityManagerFactory; - @Before - public void checkJta() { + @BeforeEach + void checkJta() { assertThat( entityManagerFactory.unwrap( SessionFactoryImplementor.class ) .getServiceRegistry().getService( TransactionCoordinatorBuilder.class ) ) .returns( true, TransactionCoordinatorBuilder::isJta ); @@ -60,7 +60,7 @@ public void checkJta() { } @Test - public void test() throws Exception { + void test() throws Exception { Snert snert = new Snert(); snert.setId( 1L ); snert.setName( "dave" ); diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java index f1f9d6382ae..6cf108d92f5 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/jta/timeout/TransactionTimeoutJtaAndSpringOutboxIT.java @@ -17,9 +17,9 @@ import org.hibernate.search.integrationtest.spring.jta.dao.SnertDAO; import org.hibernate.search.integrationtest.spring.jta.entity.Snert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import com.atomikos.icatch.jta.TransactionManagerImp; @@ -27,13 +27,13 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest(classes = JtaAndSpringOutboxApplicationConfiguration.class) @ActiveProfiles({ "jta", "outbox", "transaction-timeout" }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class TransactionTimeoutJtaAndSpringOutboxIT { +class TransactionTimeoutJtaAndSpringOutboxIT { @Autowired private SnertDAO snertDAO; @@ -41,8 +41,8 @@ public class TransactionTimeoutJtaAndSpringOutboxIT { @Autowired private EntityManagerFactory entityManagerFactory; - @Before - public void checkJta() { + @BeforeEach + void checkJta() { TimeoutFailureCollector.EXCEPTIONS.clear(); assertThat( entityManagerFactory.unwrap( SessionFactoryImplementor.class ) @@ -56,7 +56,7 @@ public void checkJta() { } @Test - public void test() throws Exception { + void test() throws Exception { Snert snert = new Snert(); snert.setId( 1L ); snert.setName( "dave" ); diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/outbox/TransactionOutboxIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/outbox/TransactionOutboxIT.java index 4037b31d0c8..c0f13003e4b 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/outbox/TransactionOutboxIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/outbox/TransactionOutboxIT.java @@ -12,12 +12,12 @@ import org.hibernate.search.integrationtest.spring.testsupport.AbstractSpringITConfig; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.CoordinationStrategyExpectations; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -27,15 +27,15 @@ import org.springframework.stereotype.Service; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @ActiveProfiles(profiles = { "outbox" }) -public class TransactionOutboxIT { +class TransactionOutboxIT { @Configuration @EntityScan @@ -51,14 +51,14 @@ public BackendMock backendMock() { } @Autowired - @Rule + @RegisterExtension public BackendMock backendMock; @Autowired private HelperService helperService; @Test - public void persist() { + void persist() { Integer id = 1; backendMock.expectWorks( IndexedEntity.NAME ) diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/sessionproxy/SessionProxyIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/sessionproxy/SessionProxyIT.java index f59291550c6..e7b627d4b0f 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/sessionproxy/SessionProxyIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/sessionproxy/SessionProxyIT.java @@ -23,14 +23,14 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -39,7 +39,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Service; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.support.TransactionTemplate; @@ -48,10 +48,10 @@ * one can create a single SearchSession for all threads, and it will correctly use the correct EntityManager * depending on the current thread. */ -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) @SpringBootTest @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) -public class SessionProxyIT { +class SessionProxyIT { @Configuration @EntityScan @@ -62,7 +62,7 @@ public static class SpringConfig extends AbstractSpringITConfig { private static boolean needsInit; @Autowired - @Rule + @RegisterExtension public BackendMock backendMock; @Autowired @@ -71,13 +71,13 @@ public static class SpringConfig extends AbstractSpringITConfig { @Autowired private PlatformTransactionManager transactionManager; - @BeforeClass - public static void beforeClass() { + @BeforeAll + static void beforeClass() { needsInit = true; } - @Before - public void before() { + @BeforeEach + void before() { if ( needsInit ) { TransactionTemplate template = new TransactionTemplate( transactionManager ); backendMock.inLenientMode( () -> template.execute( ignored -> { @@ -89,7 +89,7 @@ public void before() { } @Test - public void useSingleSearchSessionFromMultipleThreads() { + void useSingleSearchSessionFromMultipleThreads() { TransactionTemplate template = new TransactionTemplate( transactionManager ); template.execute( status -> { diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractSpringITConfig.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractSpringITConfig.java index cf283c5533b..aeff6819366 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractSpringITConfig.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/testsupport/AbstractSpringITConfig.java @@ -9,7 +9,7 @@ import java.util.concurrent.CompletableFuture; import org.hibernate.SessionFactory; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; @@ -29,7 +29,7 @@ public abstract class AbstractSpringITConfig { @Bean public BackendMock backendMock() { - return new BackendMock().ignoreSchema(); + return BackendMock.create().ignoreSchema(); } @Bean diff --git a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java index f355469c2bc..eedf18fb581 100644 --- a/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java +++ b/integrationtest/mapper/orm-spring/src/test/java/org/hibernate/search/integrationtest/spring/transaction/TransactionIT.java @@ -12,12 +12,12 @@ import org.hibernate.search.integrationtest.spring.testsupport.AbstractSpringITConfig; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -27,16 +27,16 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -@RunWith(SpringRunner.class) +@ExtendWith(SpringExtension.class) // Adding a property here is just a "workaround" to make sure that a different context is used for this test // otherwise there can be build errors when running all the tests via maven. @SpringBootTest(properties = "spring.jta.atomikos.datasource.bean-name=hsearch-datasource1") @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) -public class TransactionIT { +class TransactionIT { @Configuration @EntityScan @@ -45,7 +45,7 @@ public static class SpringConfig extends AbstractSpringITConfig { } @Autowired - @Rule + @RegisterExtension public BackendMock backendMock; @Autowired @@ -53,7 +53,7 @@ public static class SpringConfig extends AbstractSpringITConfig { @Test @TestForIssue(jiraKey = "HSEARCH-1270") - public void innerTransactionRollback() { + void innerTransactionRollback() { Integer outerId = 1; Integer innerId = 2; @@ -72,7 +72,7 @@ public void innerTransactionRollback() { @Test @TestForIssue(jiraKey = "HSEARCH-1270") - public void innerTransactionRollback_flushBeforeInner() { + void innerTransactionRollback_flushBeforeInner() { Integer outerId = 1; Integer innerId = 2; diff --git a/integrationtest/mapper/orm/pom.xml b/integrationtest/mapper/orm/pom.xml index 4a25d6b40ad..5f137c99b5a 100644 --- a/integrationtest/mapper/orm/pom.xml +++ b/integrationtest/mapper/orm/pom.xml @@ -36,11 +36,6 @@ ${jdbc.driver.artifactId} test - - io.takari.junit - takari-cpsuite - test - diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AbstractIndexingPlanFilterIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AbstractIndexingPlanFilterIT.java index 9873ffe786f..6b28bb84aad 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AbstractIndexingPlanFilterIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AbstractIndexingPlanFilterIT.java @@ -19,6 +19,7 @@ import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToMany; +import org.hibernate.SessionFactory; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; @@ -27,25 +28,20 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.rules.MethodRule; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.RegisterExtension; public abstract class AbstractIndexingPlanFilterIT { - @ClassRule - public static BackendMock backendMock = new BackendMock(); + @RegisterExtension + public static BackendMock backendMock = BackendMock.createGlobal(); - @ClassRule - public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); + @RegisterExtension + public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule - public MethodRule setupHolderMethodRule = setupHolder.methodRule(); protected static final String DYNAMIC_BASE_TYPE_A = "DynamicA"; protected static final String DYNAMIC_SUBTYPE_B = "DynamicA_B"; protected static final String DYNAMIC_SUBTYPE_C = "DynamicA_C"; @@ -54,10 +50,9 @@ public abstract class AbstractIndexingPlanFilterIT { protected static final String DYNAMIC_NOT_INDEXED_BASE_TYPE_B = "DynamicNotIndexedB"; protected static final String DYNAMIC_NOT_INDEXED_SUBTYPE_B_B = "DynamicNotIndexedSubTypeB_B"; + protected SessionFactory sessionFactory; - - @ReusableOrmSetupHolder.Setup - public void setup(OrmSetupHelper.SetupContext setupContext) { + public SessionFactory setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "indexedField", String.class ) .objectField( @@ -78,8 +73,10 @@ public void setup(OrmSetupHelper.SetupContext setupContext) { .expectSchema( EntityFromSuperclass.INDEX, b -> b.field( "indexedField", String.class ) ) .expectSchema( IndexedSubtypeOfNotIndexedEntity.INDEX, b -> b.field( "indexedField", String.class ) ); - setupContext.withAnnotatedTypes( IndexedEntity.class, OtherIndexedEntity.class, ContainedEntity.class, - EntityA.class, Entity1A.class, Entity1B.class, Entity2A.class, EntityFromSuperclass.class, SuperClass.class, + OrmSetupHelper.SetupContext setupContext = ormSetupHelper.start().withAnnotatedTypes( IndexedEntity.class, + OtherIndexedEntity.class, ContainedEntity.class, + EntityA.class, Entity1A.class, Entity1B.class, Entity2A.class, EntityFromSuperclass.class, + SuperClass.class, SimpleNotIndexedEntity.class, NotIndexedEntityFromSuperclass.class, NotIndexedEntity.class, IndexedSubtypeOfNotIndexedEntity.class ); @@ -119,11 +116,15 @@ public void setup(OrmSetupHelper.SetupContext setupContext) { .field( "propertyOfC", LocalDate.class ) ) .expectSchema( DYNAMIC_INDEXED_SUBTYPE_A_B, b -> b .field( "propertyOfB", Integer.class ) ); + + return setupContext.setup(); } - @Before - public void clearFilter() throws Exception { - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + @BeforeEach + void clearFilter() throws Exception { + sessionFactory = setup(); + + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> { /*clear out any settings from tests*/ } ); } diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/ApplicationIndexingPlanFilterIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/ApplicationIndexingPlanFilterIT.java index ae421c15f43..f7879d2adce 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/ApplicationIndexingPlanFilterIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/ApplicationIndexingPlanFilterIT.java @@ -6,23 +6,24 @@ */ package org.hibernate.search.integrationtest.mapper.orm.automaticindexing; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; import java.util.Arrays; import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.util.common.SearchException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ApplicationIndexingPlanFilterIT extends AbstractIndexingPlanFilterIT { +class ApplicationIndexingPlanFilterIT extends AbstractIndexingPlanFilterIT { @Test - public void directPersistUpdateDeleteApplicationFilter() { - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void directPersistUpdateDeleteApplicationFilter() { + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); entity1.setId( 1 ); @@ -41,17 +42,17 @@ public void directPersistUpdateDeleteApplicationFilter() { } ); backendMock.verifyExpectationsMet(); - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = session.get( IndexedEntity.class, 1 ); entity1.setIndexedField( "updatedValue" ); } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = session.get( IndexedEntity.class, 1 ); entity1.getContainedIndexedEmbedded().forEach( e -> e.setContainingAsIndexedEmbedded( null ) ); @@ -63,11 +64,11 @@ public void directPersistUpdateDeleteApplicationFilter() { } @Test - public void directPersistUpdateDeleteApplicationFilterByName() { - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void directPersistUpdateDeleteApplicationFilterByName() { + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.INDEX ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); entity1.setId( 1 ); @@ -86,17 +87,17 @@ public void directPersistUpdateDeleteApplicationFilterByName() { } ); backendMock.verifyExpectationsMet(); - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.INDEX ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = session.get( IndexedEntity.class, 1 ); entity1.setIndexedField( "updatedValue" ); } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = session.get( IndexedEntity.class, 1 ); entity1.getContainedIndexedEmbedded().forEach( e -> e.setContainingAsIndexedEmbedded( null ) ); @@ -108,14 +109,14 @@ public void directPersistUpdateDeleteApplicationFilterByName() { } @Test - public void hierarchyFiltering() { + void hierarchyFiltering() { // exclude all except one specific class. - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.class ) .include( Entity2A.class ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { session.persist( new EntityA( 1, "test" ) ); session.persist( new Entity1A( 2, "test" ) ); session.persist( new Entity1B( 3, "test" ) ); @@ -127,11 +128,11 @@ public void hierarchyFiltering() { backendMock.verifyExpectationsMet(); // exclude all except one class branch. - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.class ) .include( Entity1A.class ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { session.persist( new EntityA( 10, "test" ) ); session.persist( new Entity1A( 20, "test" ) ); session.persist( new Entity1B( 30, "test" ) ); @@ -145,10 +146,10 @@ public void hierarchyFiltering() { backendMock.verifyExpectationsMet(); // only include - should include all since no excludes. - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.include( Entity1A.class ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { session.persist( new EntityA( 100, "test" ) ); session.persist( new Entity1A( 200, "test" ) ); session.persist( new Entity1B( 300, "test" ) ); @@ -167,8 +168,8 @@ public void hierarchyFiltering() { } @Test - public void sameClassFails() { - assertThatThrownBy( () -> Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void sameClassFails() { + assertThatThrownBy( () -> Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.class ) .include( EntityA.class ) ) @@ -180,7 +181,7 @@ public void sameClassFails() { "Already excluded types:" ); - assertThatThrownBy( () -> Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + assertThatThrownBy( () -> Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.include( EntityA.class ) .exclude( EntityA.class ) ) @@ -194,8 +195,8 @@ public void sameClassFails() { } @Test - public void sameNameFails() { - assertThatThrownBy( () -> Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void sameNameFails() { + assertThatThrownBy( () -> Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.include( EntityA.INDEX ) .exclude( EntityA.INDEX ) ) @@ -209,11 +210,11 @@ public void sameNameFails() { } @Test - public void applicationFilterDisableAll() { - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void applicationFilterDisableAll() { + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.class ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { session.persist( new EntityA( 1, "test" ) ); session.persist( new Entity1A( 2, "test" ) ); session.persist( new Entity1B( 3, "test" ) ); @@ -223,11 +224,11 @@ public void applicationFilterDisableAll() { } @Test - public void applicationFilterDisableAllByName() { - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void applicationFilterDisableAllByName() { + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.INDEX ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { session.persist( new EntityA( 1, "test" ) ); session.persist( new Entity1A( 2, "test" ) ); session.persist( new Entity1B( 3, "test" ) ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingBasicIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingBasicIT.java index 80f751fe456..48de3d984e0 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingBasicIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingBasicIT.java @@ -21,8 +21,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -41,7 +41,7 @@ public class AutomaticIndexingBasicIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingConcurrentModificationInDifferentTypeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingConcurrentModificationInDifferentTypeIT.java index 8f72a074f9a..0e7535ab7e2 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingConcurrentModificationInDifferentTypeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingConcurrentModificationInDifferentTypeIT.java @@ -14,7 +14,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -28,7 +28,7 @@ public class AutomaticIndexingConcurrentModificationInDifferentTypeIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingConcurrentModificationInSameTypeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingConcurrentModificationInSameTypeIT.java index 55818f82227..28133ea44f3 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingConcurrentModificationInSameTypeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingConcurrentModificationInSameTypeIT.java @@ -14,7 +14,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -28,7 +28,7 @@ public class AutomaticIndexingConcurrentModificationInSameTypeIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingDirtyCheckIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingDirtyCheckIT.java index 0e2afb4a626..8ab5ab3a4e9 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingDirtyCheckIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingDirtyCheckIT.java @@ -13,19 +13,19 @@ import org.hibernate.SessionFactory; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test warning message for enabling/disabling the dirty check. */ @TestForIssue(jiraKey = "HSEARCH-4866") -public class AutomaticIndexingDirtyCheckIT { +class AutomaticIndexingDirtyCheckIT { private static final String DEPRECATED_PROPERTY_MESSAGE = "Configuration property " + "'hibernate.search.automatic_indexing.enable_dirty_check' is deprecated. " @@ -34,13 +34,13 @@ public class AutomaticIndexingDirtyCheckIT { + "After the removal of this property in a future version, " + "a dirty check will always be performed when considering whether to trigger reindexing."; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); private SessionFactory setup(Boolean enabled) { @@ -56,7 +56,7 @@ private SessionFactory setup(Boolean enabled) { } @Test - public void enabled_default() { + void enabled_default() { logged.expectMessage( DEPRECATED_PROPERTY_MESSAGE ).never(); setup( null ); @@ -65,7 +65,7 @@ public void enabled_default() { } @Test - public void enabled_explicit() { + void enabled_explicit() { logged.expectMessage( DEPRECATED_PROPERTY_MESSAGE ).never(); setup( true ); @@ -74,7 +74,7 @@ public void enabled_explicit() { } @Test - public void disabled() { + void disabled() { logged.expectMessage( DEPRECATED_PROPERTY_MESSAGE ).once(); setup( false ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingElementCollectionIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingElementCollectionIT.java index b2dc3e9562a..7c284898b2e 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingElementCollectionIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingElementCollectionIT.java @@ -21,7 +21,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -40,7 +40,7 @@ public class AutomaticIndexingElementCollectionIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingEmbeddableIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingEmbeddableIT.java index 8b7d0bad6c9..e9d4fa0a9fb 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingEmbeddableIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingEmbeddableIT.java @@ -33,9 +33,9 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ObjectPath; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.StubTreeNodeDiffer; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -50,7 +50,7 @@ public class AutomaticIndexingEmbeddableIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingEnabledIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingEnabledIT.java index 48df32fff94..fd7ed57f38d 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingEnabledIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingEnabledIT.java @@ -21,30 +21,28 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test enabling/disabling automatic indexing. */ @TestForIssue(jiraKey = { "HSEARCH-4268", "HSEARCH-4616" }) -@RunWith(Parameterized.class) -public class AutomaticIndexingEnabledIT { +class AutomaticIndexingEnabledIT { - @Parameterized.Parameters(name = "Configuration Setting = {0}") @SuppressWarnings("deprecation") - public static List data() { - return Arrays.asList( new Object[][] { - { HibernateOrmMapperSettings.AUTOMATIC_INDEXING_ENABLED }, - { HibernateOrmMapperSettings.INDEXING_LISTENERS_ENABLED } - } ); + public static List params() { + return Arrays.asList( + Arguments.of( HibernateOrmMapperSettings.AUTOMATIC_INDEXING_ENABLED ), + Arguments.of( HibernateOrmMapperSettings.INDEXING_LISTENERS_ENABLED ) + ); } private static final String DEPRECATED_STRATEGY_PROPERTY_MESSAGE = "Configuration property " @@ -55,20 +53,17 @@ public static List data() { + "'hibernate.search.automatic_indexing.enabled' is deprecated;" + " use 'hibernate.search.indexing.listeners.enabled' instead"; - @Parameterized.Parameter - public String configurationSetting; - - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @SuppressWarnings("deprecation") // because of HibernateOrmMapperSettings.AUTOMATIC_INDEXING_ENABLED - private SessionFactory setup(Boolean enabled, String strategyName) { + private SessionFactory setup(Boolean enabled, String strategyName, String configurationSetting) { if ( enabled != null && HibernateOrmMapperSettings.AUTOMATIC_INDEXING_ENABLED.equals( configurationSetting ) ) { logged.expectMessage( DEPRECATED_AUTOMATIC_INDEXING_ENABLED_PROPERTY_MESSAGE ).once(); } @@ -85,11 +80,12 @@ private SessionFactory setup(Boolean enabled, String strategyName) { return sessionFactory; } - @Test - public void enabled_default() { + @ParameterizedTest(name = "Configuration Setting = {0}") + @MethodSource("params") + void enabled_default(String configurationSetting) { logged.expectMessage( DEPRECATED_STRATEGY_PROPERTY_MESSAGE ).never(); - SessionFactory sessionFactory = setup( null, null ); + SessionFactory sessionFactory = setup( null, null, configurationSetting ); with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity( 1, "initialValue" ); @@ -104,11 +100,12 @@ public void enabled_default() { backendMock.verifyExpectationsMet(); } - @Test - public void enabled_explicit() { + @ParameterizedTest(name = "Configuration Setting = {0}") + @MethodSource("params") + void enabled_explicit(String configurationSetting) { logged.expectMessage( DEPRECATED_STRATEGY_PROPERTY_MESSAGE ).never(); - SessionFactory sessionFactory = setup( true, null ); + SessionFactory sessionFactory = setup( true, null, configurationSetting ); with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity( 1, "initialValue" ); @@ -123,11 +120,12 @@ public void enabled_explicit() { backendMock.verifyExpectationsMet(); } - @Test - public void disabled() { + @ParameterizedTest(name = "Configuration Setting = {0}") + @MethodSource("params") + void disabled(String configurationSetting) { logged.expectMessage( DEPRECATED_STRATEGY_PROPERTY_MESSAGE ).never(); - SessionFactory sessionFactory = setup( false, null ); + SessionFactory sessionFactory = setup( false, null, configurationSetting ); with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity( 1, "initialValue" ); @@ -139,11 +137,12 @@ public void disabled() { backendMock.verifyExpectationsMet(); } - @Test - public void legacy_strategy_none() { + @ParameterizedTest(name = "Configuration Setting = {0}") + @MethodSource("params") + void legacy_strategy_none(String configurationSetting) { logged.expectMessage( DEPRECATED_STRATEGY_PROPERTY_MESSAGE ).once(); - SessionFactory sessionFactory = setup( null, "none" ); + SessionFactory sessionFactory = setup( null, "none", configurationSetting ); with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity( 1, "initialValue" ); @@ -155,11 +154,12 @@ public void legacy_strategy_none() { backendMock.verifyExpectationsMet(); } - @Test - public void legacy_strategy_session() { + @ParameterizedTest(name = "Configuration Setting = {0}") + @MethodSource("params") + void legacy_strategy_session(String configurationSetting) { logged.expectMessage( DEPRECATED_STRATEGY_PROPERTY_MESSAGE ).once(); - SessionFactory sessionFactory = setup( null, "session" ); + SessionFactory sessionFactory = setup( null, "session", configurationSetting ); with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity( 1, "initialValue" ); @@ -174,9 +174,10 @@ public void legacy_strategy_session() { backendMock.verifyExpectationsMet(); } - @Test @SuppressWarnings("deprecation") - public void conflictingSettingsUsed() { + @ParameterizedTest(name = "Configuration Setting = {0}") + @MethodSource("params") + void conflictingSettingsUsed(String configurationSetting) { backendMock.expectSchema( IndexedEntity.NAME, b -> b .field( "text", String.class ) ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingMappedSuperclassIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingMappedSuperclassIT.java index 22ec2e0b648..bc2d82eef73 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingMappedSuperclassIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingMappedSuperclassIT.java @@ -20,7 +20,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -35,7 +35,7 @@ public class AutomaticIndexingMappedSuperclassIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingMultiTenancyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingMultiTenancyIT.java index e45d3152967..2eb0d52d2aa 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingMultiTenancyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingMultiTenancyIT.java @@ -17,12 +17,12 @@ import org.hibernate.search.engine.backend.analysis.AnalyzerNames; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Simple test to check that automatic indexing works correctly when multi-tenancy is enabled. @@ -31,19 +31,19 @@ * from a background thread, since they will have to remember the tenant ID somehow. */ @TestForIssue(jiraKey = "HSEARCH-4316") -public class AutomaticIndexingMultiTenancyIT { +class AutomaticIndexingMultiTenancyIT { private static final String TENANT_1_ID = "tenant1"; private static final String TENANT_2_ID = "tenant2"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void test() throws InterruptedException { + void test() throws InterruptedException { backendMock.expectSchema( IndexedEntity.NAME, b -> b .field( "text", String.class, f -> f.analyzerName( AnalyzerNames.DEFAULT ) ) ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingNonEntityIdDocumentIdIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingNonEntityIdDocumentIdIT.java index 60b5736048f..47d84e8244c 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingNonEntityIdDocumentIdIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingNonEntityIdDocumentIdIT.java @@ -19,7 +19,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -37,7 +37,7 @@ public class AutomaticIndexingNonEntityIdDocumentIdIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingOverReindexingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingOverReindexingIT.java index 7f618e461f9..cb460fccf2d 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingOverReindexingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingOverReindexingIT.java @@ -24,7 +24,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.TypeBinding; import org.hibernate.search.mapper.pojo.model.PojoElementAccessor; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -77,7 +77,7 @@ public class AutomaticIndexingOverReindexingIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingRoutingBridgeConditionalIndexingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingRoutingBridgeConditionalIndexingIT.java index 26ad87c0d72..477cce78592 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingRoutingBridgeConditionalIndexingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingRoutingBridgeConditionalIndexingIT.java @@ -19,7 +19,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.route.DocumentRoutes; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -32,7 +32,7 @@ public class AutomaticIndexingRoutingBridgeConditionalIndexingIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingRoutingBridgeRoutingKeyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingRoutingBridgeRoutingKeyIT.java index c6430e16536..f3c568346aa 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingRoutingBridgeRoutingKeyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/AutomaticIndexingRoutingBridgeRoutingKeyIT.java @@ -21,8 +21,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.route.DocumentRoutes; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -35,7 +35,7 @@ public class AutomaticIndexingRoutingBridgeRoutingKeyIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/SessionIndexingPlanFilterIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/SessionIndexingPlanFilterIT.java index 9fcb0622c0d..a1811145e4c 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/SessionIndexingPlanFilterIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/SessionIndexingPlanFilterIT.java @@ -6,7 +6,8 @@ */ package org.hibernate.search.integrationtest.mapper.orm.automaticindexing; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; import java.time.LocalDate; import java.time.Month; @@ -17,13 +18,13 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.util.common.SearchException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SessionIndexingPlanFilterIT extends AbstractIndexingPlanFilterIT { +class SessionIndexingPlanFilterIT extends AbstractIndexingPlanFilterIT { @Test - public void directPersistUpdateDelete() { - setupHolder.runInTransaction( session -> { + void directPersistUpdateDelete() { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) ); IndexedEntity entity1 = new IndexedEntity(); @@ -43,7 +44,7 @@ public void directPersistUpdateDelete() { } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) ); IndexedEntity entity1 = session.get( IndexedEntity.class, 1 ); @@ -52,7 +53,7 @@ public void directPersistUpdateDelete() { } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) ); IndexedEntity entity1 = session.get( IndexedEntity.class, 1 ); @@ -66,8 +67,8 @@ public void directPersistUpdateDelete() { } @Test - public void directPersistUpdateDeleteOfNotDisabledEntity() { - setupHolder.runInTransaction( session -> { + void directPersistUpdateDeleteOfNotDisabledEntity() { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) ); IndexedEntity entity0 = new IndexedEntity(); @@ -99,7 +100,7 @@ public void directPersistUpdateDeleteOfNotDisabledEntity() { } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) ); OtherIndexedEntity entity1 = session.get( OtherIndexedEntity.class, 10 ); @@ -113,7 +114,7 @@ public void directPersistUpdateDeleteOfNotDisabledEntity() { } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) ); IndexedEntity entity0 = session.get( IndexedEntity.class, 1 ); @@ -132,9 +133,9 @@ public void directPersistUpdateDeleteOfNotDisabledEntity() { } @Test - public void hierarchyFiltering() { + void hierarchyFiltering() { // exclude all except one specific class. - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.class ) .include( Entity2A.class ) ); @@ -149,7 +150,7 @@ public void hierarchyFiltering() { backendMock.verifyExpectationsMet(); // exclude all except one class branch. - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.class ) .include( Entity1A.class ) ); @@ -166,7 +167,7 @@ public void hierarchyFiltering() { backendMock.verifyExpectationsMet(); // only include - should include all since no excludes. - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.include( Entity1A.class ) ); session.persist( new EntityA( 100, "test" ) ); @@ -187,8 +188,8 @@ public void hierarchyFiltering() { } @Test - public void sameClassFails() { - setupHolder.runInTransaction( session -> { + void sameClassFails() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.class ) .include( EntityA.class ) ) ).isInstanceOf( SearchException.class ) @@ -212,8 +213,8 @@ public void sameClassFails() { } @Test - public void sameNameFails() { - setupHolder.runInTransaction( session -> { + void sameNameFails() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.include( EntityA.INDEX ) .exclude( EntityA.INDEX ) @@ -229,11 +230,11 @@ public void sameNameFails() { } @Test - public void applicationFilterDisableAll() { - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void applicationFilterDisableAll() { + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.class ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { session.persist( new EntityA( 1, "test" ) ); session.persist( new Entity1A( 2, "test" ) ); session.persist( new Entity1B( 3, "test" ) ); @@ -241,7 +242,7 @@ public void applicationFilterDisableAll() { } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.include( Entity2A.class ) ); session.persist( new EntityA( 10, "test" ) ); @@ -256,12 +257,12 @@ public void applicationFilterDisableAll() { } @Test - public void applicationFilterExcludeSessionInclude() { - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void applicationFilterExcludeSessionInclude() { + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( Entity2A.class ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.include( Entity2A.class ) ); session.persist( new Entity2A( 40, "test" ) ); @@ -273,13 +274,13 @@ public void applicationFilterExcludeSessionInclude() { } @Test - public void applicationFilterIncludeOneSubtypeSessionIncludesAnother() { - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void applicationFilterIncludeOneSubtypeSessionIncludesAnother() { + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( EntityA.class ) .include( Entity1B.class ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.include( Entity2A.class ) ); session.persist( new Entity1B( 30, "test" ) ); @@ -294,8 +295,8 @@ public void applicationFilterIncludeOneSubtypeSessionIncludesAnother() { } @Test - public void filterByMappedSuperclass() { - setupHolder.runInTransaction( session -> { + void filterByMappedSuperclass() { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( SuperClass.class ) ); session.persist( new EntityFromSuperclass( 100, "test" ) ); @@ -304,8 +305,8 @@ public void filterByMappedSuperclass() { } @Test - public void filterByNotIndexedEntity() { - setupHolder.runInTransaction( session -> { + void filterByNotIndexedEntity() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( SimpleNotIndexedEntity.class ) ) @@ -319,8 +320,8 @@ public void filterByNotIndexedEntity() { } @Test - public void filterByRandomClass() { - setupHolder.runInTransaction( session -> { + void filterByRandomClass() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( NotAnEntity.class ) ) @@ -334,8 +335,8 @@ public void filterByRandomClass() { } @Test - public void filterByNotIndexedEntityFormSupertypeWithIndexedSubtype() { - setupHolder.runInTransaction( session -> { + void filterByNotIndexedEntityFormSupertypeWithIndexedSubtype() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( NotIndexedEntityFromSuperclass.class ) ) @@ -349,8 +350,8 @@ public void filterByNotIndexedEntityFormSupertypeWithIndexedSubtype() { } @Test - public void filterByIndexedTypeNotAnEntity() { - setupHolder.runInTransaction( session -> { + void filterByIndexedTypeNotAnEntity() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( IndexedNotAnEntity.class ) ) @@ -364,8 +365,8 @@ public void filterByIndexedTypeNotAnEntity() { } @Test - public void filterByIntegerShouldFail() { - setupHolder.runInTransaction( session -> { + void filterByIntegerShouldFail() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.include( Integer.class ) ) @@ -376,7 +377,7 @@ public void filterByIntegerShouldFail() { "This class is neither an entity type mapped in Hibernate Search nor a superclass of such entity type" ); } ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( Integer.class ) ) @@ -390,8 +391,8 @@ public void filterByIntegerShouldFail() { } @Test - public void filterBySomeString() { - setupHolder.runInTransaction( session -> { + void filterBySomeString() { + with( sessionFactory ).runInTransaction( session -> { String name = "this is not a name that should work"; assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( name ) @@ -417,8 +418,8 @@ public void filterBySomeString() { } @Test - public void filterByContainedEntityWontAffectContainingOnes() { - setupHolder.runInTransaction( session -> { + void filterByContainedEntityWontAffectContainingOnes() { + with( sessionFactory ).runInTransaction( session -> { // to prepare data we ignore containing/indexed entity Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) @@ -441,7 +442,7 @@ public void filterByContainedEntityWontAffectContainingOnes() { } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { // now disable contained entity to not produce updates on containing: Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( ContainedEntity.class ) @@ -450,7 +451,7 @@ public void filterByContainedEntityWontAffectContainingOnes() { entity1.setIndexedField( "updatedValue" ); } ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( IndexedEntity.class ) ); @@ -465,8 +466,8 @@ public void filterByContainedEntityWontAffectContainingOnes() { } @Test - public void filterByInterfaceMustFail() { - setupHolder.runInTransaction( session -> { + void filterByInterfaceMustFail() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( InterfaceA.class ) ) @@ -489,8 +490,8 @@ public void filterByInterfaceMustFail() { } @Test - public void excludeByNameOfNotIndexedSupertype() { - setupHolder.runInTransaction( session -> { + void excludeByNameOfNotIndexedSupertype() { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( NotIndexedEntity.NAME ) ); session.persist( new IndexedSubtypeOfNotIndexedEntity( 40, "test", "test" ) ); @@ -500,8 +501,8 @@ public void excludeByNameOfNotIndexedSupertype() { // Maps are used to represent dynamic types and we want to make sure that passing a Map won't work. @Test - public void filterByMapInterfaceMustFail() { - setupHolder.runInTransaction( session -> { + void filterByMapInterfaceMustFail() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( Map.class ) ) @@ -515,8 +516,8 @@ public void filterByMapInterfaceMustFail() { } @Test - public void dynamicTypeByNameDirectPersistUpdateDelete() { - setupHolder.runInTransaction( session -> { + void dynamicTypeByNameDirectPersistUpdateDelete() { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( DYNAMIC_BASE_TYPE_A ) ); Map entity1 = new HashMap<>(); @@ -534,7 +535,7 @@ public void dynamicTypeByNameDirectPersistUpdateDelete() { } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( DYNAMIC_BASE_TYPE_A ) ); @SuppressWarnings("unchecked") @@ -543,7 +544,7 @@ public void dynamicTypeByNameDirectPersistUpdateDelete() { } ); backendMock.verifyExpectationsMet(); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( DYNAMIC_BASE_TYPE_A ) ); session.remove( session.get( DYNAMIC_SUBTYPE_B, 1 ) ); @@ -554,11 +555,11 @@ public void dynamicTypeByNameDirectPersistUpdateDelete() { } @Test - public void dynamicTypeByNameApplicationDisableAllSessionEnableSubtype() { - Search.mapping( setupHolder.entityManagerFactory() ).indexingPlanFilter( + void dynamicTypeByNameApplicationDisableAllSessionEnableSubtype() { + Search.mapping( sessionFactory ).indexingPlanFilter( ctx -> ctx.exclude( DYNAMIC_BASE_TYPE_A ) ); - setupHolder.runInTransaction( session -> { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.include( DYNAMIC_SUBTYPE_B ) ); Map entity1 = new HashMap<>(); @@ -582,8 +583,8 @@ public void dynamicTypeByNameApplicationDisableAllSessionEnableSubtype() { } @Test - public void excludeByNameOfNotIndexedSupertypeDynamicTypes() { - setupHolder.runInTransaction( session -> { + void excludeByNameOfNotIndexedSupertypeDynamicTypes() { + with( sessionFactory ).runInTransaction( session -> { Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( DYNAMIC_NOT_INDEXED_BASE_TYPE_A ) ); Map entity1 = new HashMap<>(); @@ -596,8 +597,8 @@ public void excludeByNameOfNotIndexedSupertypeDynamicTypes() { } @Test - public void excludeByNameOfNotIndexedSupertypeThatHasNoIndexedOrContainedSubtypesDynamicTypes() { - setupHolder.runInTransaction( session -> { + void excludeByNameOfNotIndexedSupertypeThatHasNoIndexedOrContainedSubtypesDynamicTypes() { + with( sessionFactory ).runInTransaction( session -> { assertThatThrownBy( () -> Search.session( session ).indexingPlanFilter( ctx -> ctx.exclude( DYNAMIC_NOT_INDEXED_BASE_TYPE_B ) ) diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/array/AbstractAutomaticIndexingArrayIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/array/AbstractAutomaticIndexingArrayIT.java index 2a48d06cf51..6edc9c7de7c 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/array/AbstractAutomaticIndexingArrayIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/array/AbstractAutomaticIndexingArrayIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.orm.automaticindexing.array; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -22,7 +22,7 @@ public abstract class AbstractAutomaticIndexingArrayIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingAssociationDeletionIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingAssociationDeletionIT.java index 94077602e0e..51e7fd19bd7 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingAssociationDeletionIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingAssociationDeletionIT.java @@ -27,7 +27,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -54,7 +54,7 @@ public class AutomaticIndexingAssociationDeletionIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingGenericPolymorphicAssociationIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingGenericPolymorphicAssociationIT.java index 332aeb6a3da..70221d9da10 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingGenericPolymorphicAssociationIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingGenericPolymorphicAssociationIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.orm.automaticindexing.association; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.fail; import java.util.ArrayList; import java.util.List; @@ -23,7 +23,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -38,7 +38,7 @@ public class AutomaticIndexingGenericPolymorphicAssociationIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingPolymorphicInverseSideAssociationIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingPolymorphicInverseSideAssociationIT.java index 04f6327897c..fceee2736b7 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingPolymorphicInverseSideAssociationIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingPolymorphicInverseSideAssociationIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.orm.automaticindexing.association; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.fail; import java.util.ArrayList; import java.util.List; @@ -23,7 +23,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -39,7 +39,7 @@ public class AutomaticIndexingPolymorphicInverseSideAssociationIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingPolymorphicOriginalSideAssociationIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingPolymorphicOriginalSideAssociationIT.java index 8ed01c6dd73..805cdab4e53 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingPolymorphicOriginalSideAssociationIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/AutomaticIndexingPolymorphicOriginalSideAssociationIT.java @@ -22,7 +22,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -38,7 +38,7 @@ public class AutomaticIndexingPolymorphicOriginalSideAssociationIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/bytype/AbstractAutomaticIndexingAssociationBaseIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/bytype/AbstractAutomaticIndexingAssociationBaseIT.java index 3284a564021..50ded775667 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/bytype/AbstractAutomaticIndexingAssociationBaseIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/association/bytype/AbstractAutomaticIndexingAssociationBaseIT.java @@ -20,10 +20,10 @@ import org.hibernate.search.integrationtest.mapper.orm.automaticindexing.association.bytype.accessor.MultiValuedPropertyAccessor; import org.hibernate.search.integrationtest.mapper.orm.automaticindexing.association.bytype.accessor.PropertyAccessor; import org.hibernate.search.util.common.AssertionFailure; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.StubTreeNodeDiffer; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.model.StubIndexSchemaDataNode; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -174,7 +174,7 @@ protected static AssertionFailure primitiveNotSupported() { } @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AbstractAutomaticIndexingBridgeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AbstractAutomaticIndexingBridgeIT.java index b921a57ddbf..93ffe7d2fa8 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AbstractAutomaticIndexingBridgeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AbstractAutomaticIndexingBridgeIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.automaticindexing.bridge; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.ArrayList; import java.util.List; @@ -30,12 +30,12 @@ import org.hibernate.search.mapper.pojo.bridge.mapping.programmatic.PropertyBinder; import org.hibernate.search.mapper.pojo.bridge.mapping.programmatic.TypeBinder; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * An abstract base for tests dealing with automatic indexing based on Hibernate ORM entity events when @@ -43,14 +43,14 @@ */ public abstract class AbstractAutomaticIndexingBridgeIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void directPersistUpdateDelete() { + void directPersistUpdateDelete() { SessionFactory sessionFactory = setupWithTypeBridge(); with( sessionFactory ).runInTransaction( session -> { @@ -100,7 +100,7 @@ public void directPersistUpdateDelete() { } @Test - public void indirectAssociationUpdate_typeBridge() { + void indirectAssociationUpdate_typeBridge() { SessionFactory sessionFactory = setupWithTypeBridge(); with( sessionFactory ).runInTransaction( session -> { @@ -218,7 +218,7 @@ public void indirectAssociationUpdate_typeBridge() { } @Test - public void indirectValueUpdate_typeBridge() { + void indirectValueUpdate_typeBridge() { SessionFactory sessionFactory = setupWithTypeBridge(); with( sessionFactory ).runInTransaction( session -> { @@ -302,7 +302,7 @@ public void indirectValueUpdate_typeBridge() { } @Test - public void indirectAssociationUpdate_singleValuedPropertyBridge() { + void indirectAssociationUpdate_singleValuedPropertyBridge() { SessionFactory sessionFactory = setupWithSingleValuedPropertyBridge(); with( sessionFactory ).runInTransaction( session -> { @@ -677,8 +677,8 @@ private SessionFactory setupWithMultiValuedPropertyBridge() { PropertyBinder binder = createContainingEntityMultiValuedPropertyBinder(); assumeTrue( - "Multi-valued property bridges must be supported", - binder != null + binder != null, + "Multi-valued property bridges must be supported" ); backendMock.expectSchema( IndexedEntity.INDEX, b -> b diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AutomaticIndexingBridgeExplicitReindexingFunctionalIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AutomaticIndexingBridgeExplicitReindexingFunctionalIT.java index e9d81bd3881..0059c319784 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AutomaticIndexingBridgeExplicitReindexingFunctionalIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AutomaticIndexingBridgeExplicitReindexingFunctionalIT.java @@ -30,13 +30,13 @@ import org.hibernate.search.mapper.pojo.bridge.mapping.programmatic.TypeBinder; import org.hibernate.search.mapper.pojo.bridge.runtime.TypeBridgeWriteContext; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test an actual use case of explicit reindexing declaration, @@ -46,18 +46,18 @@ * tests the feature works correctly but in a setup that wouldn't require this feature. */ @TestForIssue(jiraKey = "HSEARCH-3297") -public class AutomaticIndexingBridgeExplicitReindexingFunctionalIT { +class AutomaticIndexingBridgeExplicitReindexingFunctionalIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "typeBridge", b2 -> b2 .field( "includedInTypeBridge", String.class ) @@ -83,7 +83,7 @@ public void configure(HibernateOrmMappingConfigurationContext context) { } @Test - public void test() { + void test() { // Init with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AutomaticIndexingEmbeddedBridgeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AutomaticIndexingEmbeddedBridgeIT.java index d13778fce7d..726e92785f8 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AutomaticIndexingEmbeddedBridgeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/AutomaticIndexingEmbeddedBridgeIT.java @@ -34,29 +34,29 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.TypeBinding; import org.hibernate.search.mapper.pojo.model.PojoElementAccessor; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test automatic indexing based on Hibernate ORM entity events when * {@link TypeBridge}s or {@link PropertyBridge}s are embedded in an {@link IndexedEmbedded}. */ -public class AutomaticIndexingEmbeddedBridgeIT { +class AutomaticIndexingEmbeddedBridgeIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "child", b2 -> b2 .objectField( "firstBridge", b3 -> b3 @@ -75,7 +75,7 @@ public void setup() { } @Test - public void indirectValueUpdate_embeddedBridge() { + void indirectValueUpdate_embeddedBridge() { with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); entity1.setId( 1 ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/ContainedInThroughNonContainingIndexedTypeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/ContainedInThroughNonContainingIndexedTypeIT.java index 17eff0f3dd1..16e4676f0e0 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/ContainedInThroughNonContainingIndexedTypeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/bridge/ContainedInThroughNonContainingIndexedTypeIT.java @@ -23,13 +23,13 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyBinding; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests a corner case that is not covered by @@ -38,18 +38,18 @@ * This should not matter given the current implementation, but better safe than sorry. */ @TestForIssue(jiraKey = "HSEARCH-2496") -public class ContainedInThroughNonContainingIndexedTypeIT { +class ContainedInThroughNonContainingIndexedTypeIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Containing.INDEX ); backendMock.expectAnySchema( Contained.INDEX ); @@ -62,7 +62,7 @@ public void setup() { } @Test - public void test() { + void test() { with( sessionFactory ).runInTransaction( session -> { Containing containing = new Containing(); containing.setId( 1 ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/ContainedInTriggerUnnecessaryCollectionInitializationIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/ContainedInTriggerUnnecessaryCollectionInitializationIT.java index c1f5f96cd1d..0b9df0b95ff 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/ContainedInTriggerUnnecessaryCollectionInitializationIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/ContainedInTriggerUnnecessaryCollectionInitializationIT.java @@ -8,7 +8,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assert.assertFalse; import java.util.HashSet; import java.util.Set; @@ -25,27 +24,27 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-1710") -public class ContainedInTriggerUnnecessaryCollectionInitializationIT { +class ContainedInTriggerUnnecessaryCollectionInitializationIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Group.INDEX ); backendMock.expectAnySchema( Post.INDEX ); @@ -58,7 +57,7 @@ public void setup() { } @Test - public void test() { + void test() { with( sessionFactory ).runInTransaction( session -> { Group group = new Group(); group.setId( 1 ); @@ -96,10 +95,10 @@ public void test() { // The posts should not be initialized assertThat( group.getPosts() ) .isInstanceOf( PersistentCollection.class ) - .satisfies( p -> assertFalse( - "The posts should not be initialized", - Hibernate.isInitialized( p ) - ) ); + .satisfies( p -> assertThat( Hibernate.isInitialized( p ) ) + .as( "The posts should not be initialized" ) + .isFalse() + ); group.setSomeField( "updatedValue" ); @@ -116,10 +115,10 @@ public void test() { Group group = groupFromModifyingTransaction.get(); assertThat( group.getPosts() ) .isInstanceOf( PersistentCollection.class ) - .satisfies( p -> assertFalse( - "The posts should not be initialized by Hibernate Search", - Hibernate.isInitialized( p ) - ) ); + .satisfies( p -> assertThat( Hibernate.isInitialized( p ) ) + .as( "The posts should not be initialized by Hibernate Search" ) + .isFalse() + ); } @Entity(name = "Group_") diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/IndexingProcessorProxiedAssociatedEntityIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/IndexingProcessorProxiedAssociatedEntityIT.java index 393df43dc4a..5e1a25adead 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/IndexingProcessorProxiedAssociatedEntityIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/IndexingProcessorProxiedAssociatedEntityIT.java @@ -24,7 +24,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -43,7 +43,7 @@ public class IndexingProcessorProxiedAssociatedEntityIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/ReindexingResolverProxiedAssociatedEntityIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/ReindexingResolverProxiedAssociatedEntityIT.java index a7c98ec7a0b..6b1996c0ae5 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/ReindexingResolverProxiedAssociatedEntityIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/proxy/ReindexingResolverProxiedAssociatedEntityIT.java @@ -25,7 +25,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -44,7 +44,7 @@ public class ReindexingResolverProxiedAssociatedEntityIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingIdentiferRollbackIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingIdentiferRollbackIT.java index df36bba55b9..20fa5b7c638 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingIdentiferRollbackIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingIdentiferRollbackIT.java @@ -17,7 +17,7 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; @@ -36,7 +36,7 @@ public class AutomaticIndexingIdentiferRollbackIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingOutOfTransactionIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingOutOfTransactionIT.java index d8d3dc71659..3a1b9616b6a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingOutOfTransactionIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingOutOfTransactionIT.java @@ -14,7 +14,7 @@ import org.hibernate.search.mapper.orm.work.SearchIndexingPlan; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -28,7 +28,7 @@ public class AutomaticIndexingOutOfTransactionIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingSessionFlushIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingSessionFlushIT.java index 4535fe751dd..22e0f7bc064 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingSessionFlushIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingSessionFlushIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.orm.automaticindexing.session; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import java.util.List; @@ -18,7 +18,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.work.spi.PojoIndexingPlan; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -36,7 +36,7 @@ public class AutomaticIndexingSessionFlushIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); @@ -95,7 +95,7 @@ public void onAutoFlush() { backendMock.verifyExpectationsMet(); } - assertEquals( 1, resultList.size() ); + assertThat( resultList ).hasSize( 1 ); backendMock.expectWorks( IndexedEntity.INDEX_NAME ) .executeFollowingWorks() diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingSynchronizationStrategyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingSynchronizationStrategyIT.java index dbbad952641..7c2e909fe0b 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingSynchronizationStrategyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/AutomaticIndexingSynchronizationStrategyIT.java @@ -40,12 +40,12 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Throwables; import org.hibernate.search.util.common.logging.impl.LoggerFactory; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; import org.assertj.core.api.InstanceOfAssertFactories; @@ -53,7 +53,7 @@ import org.hamcrest.CoreMatchers; @Deprecated -public class AutomaticIndexingSynchronizationStrategyIT { +class AutomaticIndexingSynchronizationStrategyIT { private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() ); @@ -67,17 +67,17 @@ public class AutomaticIndexingSynchronizationStrategyIT { private static final int ENTITY_1_ID = 1; private static final int ENTITY_2_ID = 2; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Test - public void success_async() throws InterruptedException, ExecutionException, TimeoutException { + void success_async() throws InterruptedException, ExecutionException, TimeoutException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.ASYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -92,7 +92,7 @@ public void success_async() throws InterruptedException, ExecutionException, Tim } @Test - public void success_writeSync_default() throws InterruptedException, TimeoutException, ExecutionException { + void success_writeSync_default() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( null ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -114,7 +114,7 @@ public void success_writeSync_default() throws InterruptedException, TimeoutExce } @Test - public void success_writeSync_explicit() throws InterruptedException, TimeoutException, ExecutionException { + void success_writeSync_explicit() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -136,7 +136,7 @@ public void success_writeSync_explicit() throws InterruptedException, TimeoutExc } @Test - public void success_readSync() throws InterruptedException, TimeoutException, ExecutionException { + void success_readSync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.READ_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -158,7 +158,7 @@ public void success_readSync() throws InterruptedException, TimeoutException, Ex } @Test - public void success_sync() throws InterruptedException, TimeoutException, ExecutionException { + void success_sync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -180,7 +180,7 @@ public void success_sync() throws InterruptedException, TimeoutException, Execut } @Test - public void success_override_writeSyncToSync() throws InterruptedException, TimeoutException, ExecutionException { + void success_override_writeSyncToSync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -202,7 +202,7 @@ public void success_override_writeSyncToSync() throws InterruptedException, Time } @Test - public void success_override_writeSyncToCustom() throws InterruptedException, TimeoutException, ExecutionException { + void success_override_writeSyncToCustom() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -222,7 +222,7 @@ sessionFactory, new CustomAutomaticIndexingSynchronizationStrategy( futureThatTo } @Test - public void success_custom_blocking_submitter() throws InterruptedException, TimeoutException, ExecutionException { + void success_custom_blocking_submitter() throws InterruptedException, TimeoutException, ExecutionException { AtomicReference> futureThatTookTooLong = new AtomicReference<>( null ); SessionFactory sessionFactory = setup( @@ -244,7 +244,7 @@ public void success_custom_blocking_submitter() throws InterruptedException, Tim } @Test - public void success_custom_rejected_submitter() throws InterruptedException, TimeoutException, ExecutionException { + void success_custom_rejected_submitter() throws InterruptedException, TimeoutException, ExecutionException { AtomicReference> futureThatTookTooLong = new AtomicReference<>( null ); SessionFactory sessionFactory = setup( @@ -266,7 +266,7 @@ public void success_custom_rejected_submitter() throws InterruptedException, Tim } @Test - public void failure_async() throws InterruptedException, ExecutionException, TimeoutException { + void failure_async() throws InterruptedException, ExecutionException, TimeoutException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.ASYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -294,7 +294,7 @@ public void failure_async() throws InterruptedException, ExecutionException, Tim } @Test - public void failure_writeSync_default() throws InterruptedException, TimeoutException, ExecutionException { + void failure_writeSync_default() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( null ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -319,7 +319,7 @@ public void failure_writeSync_default() throws InterruptedException, TimeoutExce } @Test - public void failure_writeSync_explicit() throws InterruptedException, TimeoutException, ExecutionException { + void failure_writeSync_explicit() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -344,7 +344,7 @@ public void failure_writeSync_explicit() throws InterruptedException, TimeoutExc } @Test - public void failure_readSync() throws InterruptedException, TimeoutException, ExecutionException { + void failure_readSync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.READ_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -369,7 +369,7 @@ public void failure_readSync() throws InterruptedException, TimeoutException, Ex } @Test - public void failure_sync() throws InterruptedException, TimeoutException, ExecutionException { + void failure_sync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -394,7 +394,7 @@ public void failure_sync() throws InterruptedException, TimeoutException, Execut } @Test - public void failure_override_writeSyncToSync() throws InterruptedException, TimeoutException, ExecutionException { + void failure_override_writeSyncToSync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -419,7 +419,7 @@ public void failure_override_writeSyncToSync() throws InterruptedException, Time } @Test - public void failure_override_writeSyncToCustom() throws InterruptedException, TimeoutException, ExecutionException { + void failure_override_writeSyncToCustom() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( AutomaticIndexingSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -446,7 +446,7 @@ sessionFactory, new CustomAutomaticIndexingSynchronizationStrategy( futureThatTo } @Test - public void failure_custom() throws InterruptedException, ExecutionException, TimeoutException { + void failure_custom() throws InterruptedException, ExecutionException, TimeoutException { AtomicReference> futureThatTookTooLong = new AtomicReference<>( null ); SessionFactory sessionFactory = setup( new CustomAutomaticIndexingSynchronizationStrategy( futureThatTookTooLong ) ); @@ -473,7 +473,7 @@ public void failure_custom() throws InterruptedException, ExecutionException, Ti } @Test - public void invalidReference() { + void invalidReference() { assertThatThrownBy( () -> setup( "invalidName" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/FlushClearEvictAllIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/FlushClearEvictAllIT.java index 67e0bc4859d..fb18a7d9440 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/FlushClearEvictAllIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/FlushClearEvictAllIT.java @@ -6,8 +6,8 @@ */ package org.hibernate.search.integrationtest.mapper.orm.automaticindexing.session; +import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assert.assertNotNull; import java.util.ArrayList; import java.util.List; @@ -28,27 +28,27 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-1350") -public class FlushClearEvictAllIT { +class FlushClearEvictAllIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private EntityManagerFactory entityManagerFactory; - @Before - public void before() { + @BeforeEach + void before() { backendMock.expectAnySchema( Post.NAME ); backendMock.expectAnySchema( Comment.NAME ); entityManagerFactory = ormSetupHelper.start().setup( Post.class, Comment.class ); @@ -56,7 +56,7 @@ public void before() { } @Test - public void test() { + void test() { with( entityManagerFactory ).runNoTransaction( entityManager -> { Post post = new Post(); post.setName( "This is a post" ); @@ -66,7 +66,7 @@ public void test() { post = entityManager.merge( post ); Long postId = post.getId(); - assertNotNull( postId ); + assertThat( postId ).isNotNull(); backendMock.expectWorks( Post.NAME ) .createFollowingWorks() diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/IndexingPlanSynchronizationStrategyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/IndexingPlanSynchronizationStrategyIT.java index 5bfc7a73ec0..e2438e1a28f 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/IndexingPlanSynchronizationStrategyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/automaticindexing/session/IndexingPlanSynchronizationStrategyIT.java @@ -41,19 +41,19 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Throwables; import org.hibernate.search.util.common.logging.impl.LoggerFactory; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; import org.assertj.core.api.InstanceOfAssertFactories; import org.awaitility.Awaitility; import org.hamcrest.CoreMatchers; -public class IndexingPlanSynchronizationStrategyIT { +class IndexingPlanSynchronizationStrategyIT { private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() ); @@ -67,17 +67,17 @@ public class IndexingPlanSynchronizationStrategyIT { private static final int ENTITY_1_ID = 1; private static final int ENTITY_2_ID = 2; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Test - public void success_async() throws InterruptedException, ExecutionException, TimeoutException { + void success_async() throws InterruptedException, ExecutionException, TimeoutException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.ASYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -92,7 +92,7 @@ public void success_async() throws InterruptedException, ExecutionException, Tim } @Test - public void success_writeSync_default() throws InterruptedException, TimeoutException, ExecutionException { + void success_writeSync_default() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( null ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -114,7 +114,7 @@ public void success_writeSync_default() throws InterruptedException, TimeoutExce } @Test - public void success_writeSync_explicit() throws InterruptedException, TimeoutException, ExecutionException { + void success_writeSync_explicit() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -136,7 +136,7 @@ public void success_writeSync_explicit() throws InterruptedException, TimeoutExc } @Test - public void success_readSync() throws InterruptedException, TimeoutException, ExecutionException { + void success_readSync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.READ_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -158,7 +158,7 @@ public void success_readSync() throws InterruptedException, TimeoutException, Ex } @Test - public void success_sync() throws InterruptedException, TimeoutException, ExecutionException { + void success_sync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -180,7 +180,7 @@ public void success_sync() throws InterruptedException, TimeoutException, Execut } @Test - public void success_override_writeSyncToSync() throws InterruptedException, TimeoutException, ExecutionException { + void success_override_writeSyncToSync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -202,7 +202,7 @@ public void success_override_writeSyncToSync() throws InterruptedException, Time } @Test - public void success_override_writeSyncToCustom() throws InterruptedException, TimeoutException, ExecutionException { + void success_override_writeSyncToCustom() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); @@ -222,7 +222,7 @@ sessionFactory, new CustomAutomaticIndexingSynchronizationStrategy( futureThatTo } @Test - public void success_custom_blocking_submitter() throws InterruptedException, TimeoutException, ExecutionException { + void success_custom_blocking_submitter() throws InterruptedException, TimeoutException, ExecutionException { AtomicReference> futureThatTookTooLong = new AtomicReference<>( null ); SessionFactory sessionFactory = setup( @@ -245,7 +245,7 @@ public void success_custom_blocking_submitter() throws InterruptedException, Tim } @Test - public void success_custom_rejected_submitter() throws InterruptedException, TimeoutException, ExecutionException { + void success_custom_rejected_submitter() throws InterruptedException, TimeoutException, ExecutionException { AtomicReference> futureThatTookTooLong = new AtomicReference<>( null ); SessionFactory sessionFactory = setup( @@ -268,7 +268,7 @@ public void success_custom_rejected_submitter() throws InterruptedException, Tim } @Test - public void failure_async() throws InterruptedException, ExecutionException, TimeoutException { + void failure_async() throws InterruptedException, ExecutionException, TimeoutException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.ASYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -296,7 +296,7 @@ public void failure_async() throws InterruptedException, ExecutionException, Tim } @Test - public void failure_writeSync_default() throws InterruptedException, TimeoutException, ExecutionException { + void failure_writeSync_default() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( null ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -321,7 +321,7 @@ public void failure_writeSync_default() throws InterruptedException, TimeoutExce } @Test - public void failure_writeSync_explicit() throws InterruptedException, TimeoutException, ExecutionException { + void failure_writeSync_explicit() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -346,7 +346,7 @@ public void failure_writeSync_explicit() throws InterruptedException, TimeoutExc } @Test - public void failure_readSync() throws InterruptedException, TimeoutException, ExecutionException { + void failure_readSync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.READ_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -371,7 +371,7 @@ public void failure_readSync() throws InterruptedException, TimeoutException, Ex } @Test - public void failure_sync() throws InterruptedException, TimeoutException, ExecutionException { + void failure_sync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -396,7 +396,7 @@ public void failure_sync() throws InterruptedException, TimeoutException, Execut } @Test - public void failure_override_writeSyncToSync() throws InterruptedException, TimeoutException, ExecutionException { + void failure_override_writeSyncToSync() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -421,7 +421,7 @@ public void failure_override_writeSyncToSync() throws InterruptedException, Time } @Test - public void failure_override_writeSyncToCustom() throws InterruptedException, TimeoutException, ExecutionException { + void failure_override_writeSyncToCustom() throws InterruptedException, TimeoutException, ExecutionException { SessionFactory sessionFactory = setup( IndexingPlanSynchronizationStrategyNames.WRITE_SYNC ); CompletableFuture indexingWorkFuture = new CompletableFuture<>(); Throwable indexingWorkException = new RuntimeException( "Some message" ); @@ -448,7 +448,7 @@ sessionFactory, new CustomAutomaticIndexingSynchronizationStrategy( futureThatTo } @Test - public void failure_custom() throws InterruptedException, ExecutionException, TimeoutException { + void failure_custom() throws InterruptedException, ExecutionException, TimeoutException { AtomicReference> futureThatTookTooLong = new AtomicReference<>( null ); SessionFactory sessionFactory = setup( @@ -476,7 +476,7 @@ public void failure_custom() throws InterruptedException, ExecutionException, Ti } @Test - public void invalidReference() { + void invalidReference() { assertThatThrownBy( () -> setup( "invalidName" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/BootstrapFailureIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/BootstrapFailureIT.java index d016110d81b..f1f215bc52f 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/BootstrapFailureIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/BootstrapFailureIT.java @@ -15,28 +15,28 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Check that a failing boot correctly propagates exceptions, * despite the complex asynchronous code used during boot. */ -public class BootstrapFailureIT { +class BootstrapFailureIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void propagateException() { + void propagateException() { assertThatThrownBy( () -> ormSetupHelper.start() .setup( FailingIndexedEntity.class, ContainedEntity.class ) ) diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/BootstrapLogsIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/BootstrapLogsIT.java index c3bbb5619b5..4be5f632436 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/BootstrapLogsIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/BootstrapLogsIT.java @@ -18,15 +18,15 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.SystemHelper; import org.hibernate.search.util.impl.test.SystemHelper.SystemPropertyRestorer; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.LogEvent; @@ -40,7 +40,7 @@ * but at least we will be aware if a warning or error is logged on every boot. */ @TestForIssue(jiraKey = "HSEARCH-3644") -public class BootstrapLogsIT { +class BootstrapLogsIT { private static final Pattern CONNECTION_POOL_WARNING_PATTERN = Pattern.compile( "CachingRegionFactory should be only used for testing" @@ -53,17 +53,17 @@ public class BootstrapLogsIT { + "||^GenerationTarget encountered exception accepting command:.*" ); - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Test - public void noSuspiciousLogEvents() { + void noSuspiciousLogEvents() { logged.expectEvent( suspiciousLogEventMatcher() ) .never(); // Also fails if a higher severity event (e.g. error) is logged @@ -75,7 +75,7 @@ public void noSuspiciousLogEvents() { @Test @SuppressWarnings("deprecation") - public void version() { + void version() { if ( Version.versionString().equals( "UNKNOWN" ) ) { throw new IllegalStateException( "Tests seem to be running from an IDE," + " or the code was compiled by an IDE." @@ -106,7 +106,7 @@ public void version() { @Test @TestForIssue(jiraKey = "HSEARCH-4503") - public void versionLoggingDisabled() { + void versionLoggingDisabled() { String propertyKey = "org.hibernate.search.version"; String expectedHibernateSearchVersion = System.getProperty( propertyKey ); if ( expectedHibernateSearchVersion == null ) { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ConfigurationProviderIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ConfigurationProviderIT.java index df3bd2995df..26e4c6d3d87 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ConfigurationProviderIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ConfigurationProviderIT.java @@ -26,24 +26,24 @@ import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ConfigurationProviderIT { +class ConfigurationProviderIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void smoke() { + void smoke() { backendMock.expectAnySchema( INDEX_NAME ); backendMock.onCreate( context -> { assertThat( context.backendConfigurationPropertySource().get( "some.backend.setting" ) ) diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/HibernateOrmIntegrationBooterIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/HibernateOrmIntegrationBooterIT.java index 67e18b05931..77288ecd9b7 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/HibernateOrmIntegrationBooterIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/HibernateOrmIntegrationBooterIT.java @@ -41,33 +41,33 @@ import org.hibernate.search.util.common.impl.Closer; import org.hibernate.search.util.common.reflect.spi.ValueHandleFactory; import org.hibernate.search.util.common.reflect.spi.ValueReadHandle; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.SimpleSessionFactoryBuilder; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.Fail; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class HibernateOrmIntegrationBooterIT { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class HibernateOrmIntegrationBooterIT { private static final String INDEX_NAME = "IndexName"; private final List toClose = new ArrayList<>(); - @Rule - public BackendMock backendMock = new BackendMock(); - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); @Mock private ValueReadHandle idValueReadHandleMock; @@ -78,8 +78,8 @@ public class HibernateOrmIntegrationBooterIT { @Mock private ValueHandleFactory valueHandleFactoryMock; - @After - public void cleanup() throws Exception { + @AfterEach + void cleanup() throws Exception { try ( Closer closer = new Closer<>() ) { closer.pushAll( AutoCloseable::close, toClose ); } @@ -87,7 +87,7 @@ public void cleanup() throws Exception { @Test @SuppressWarnings({ "unchecked", "rawtypes" }) - public void twoPhaseBoot() throws Exception { + void twoPhaseBoot() throws Exception { CompletableFuture mappingHandlePromise = new CompletableFuture<>(); HibernateOrmIntegrationBooter booter = createBooter( mappingHandlePromise, IndexedEntity.class ); Map booterGeneratedProperties = new LinkedHashMap<>(); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ObsoletePropertiesIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ObsoletePropertiesIT.java index 0d246dba01c..c9f97ac8211 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ObsoletePropertiesIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ObsoletePropertiesIT.java @@ -23,14 +23,14 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.SimpleSessionFactoryBuilder; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ObsoletePropertiesIT { +class ObsoletePropertiesIT { private static final List OBSOLETE_ROOT_LEVEL_PROPERTY_KEYS = CollectionHelper.asImmutableList( "hibernate.search.query.object_lookup_method", @@ -103,14 +103,14 @@ public class ObsoletePropertiesIT { "elasticsearch.dynamic_mapping" ); - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void obsoleteProperty() { + void obsoleteProperty() { // Generate a list of all invalid property keys we can think of List obsoletePropertyKeys = new ArrayList<>(); obsoletePropertyKeys.addAll( OBSOLETE_ROOT_LEVEL_PROPERTY_KEYS ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ShutdownFailureIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ShutdownFailureIT.java index 22dca82885e..3d9cc2cc3bd 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ShutdownFailureIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/ShutdownFailureIT.java @@ -15,12 +15,12 @@ import org.hibernate.search.mapper.pojo.bridge.runtime.ValueBridgeToIndexedValueContext; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; @@ -28,19 +28,19 @@ * Check that a failing boot correctly propagates exceptions, * despite the complex asynchronous code used during boot. */ -public class ShutdownFailureIT { +class ShutdownFailureIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule + @RegisterExtension public final ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Test - public void logException() { + void logException() { backendMock.expectAnySchema( FailingIndexedEntity.NAME ); SessionFactory sessionFactory = ormSetupHelper.start().setup( FailingIndexedEntity.class ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/UnusedPropertiesIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/UnusedPropertiesIT.java index 6710c42bcc2..4a17b98abd0 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/UnusedPropertiesIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/bootstrap/UnusedPropertiesIT.java @@ -16,33 +16,33 @@ import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.SimpleSessionFactoryBuilder; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; -public class UnusedPropertiesIT { +class UnusedPropertiesIT { private static final String KEY_UNUSED = "hibernate.search.indexes.myIndex.foo"; private static final String KEY_UNUSED_BUT_EMPTY_VALUE = "hibernate.search.indexes.myIndex.emptyValue"; private static final String KEY_UNUSED_BUT_BLANK_VALUE = "hibernate.search.indexes.myIndex.blankValue"; private static final String KEY_UNUSED_BUT_NULL_VALUE = "hibernate.search.indexes.myIndex.nullValue"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Test - public void checkDisabled_unusedProperty() { + void checkDisabled_unusedProperty() { logged.expectMessage( "some properties in the given configuration are not used" ) .never(); logged.expectEvent( Level.INFO, "Configuration property tracking is disabled" ) @@ -58,7 +58,7 @@ public void checkDisabled_unusedProperty() { } @Test - public void checkEnabledByDefault_unusedProperty() { + void checkEnabledByDefault_unusedProperty() { logged.expectEvent( Level.WARN, "Invalid configuration passed to Hibernate Search", "some properties in the given configuration are not used", @@ -83,7 +83,7 @@ public void checkEnabledByDefault_unusedProperty() { } @Test - public void checkEnabledExplicitly_noUnusedProperty() { + void checkEnabledExplicitly_noUnusedProperty() { /* * Check that the "configuration property tracking strategy" property is considered used. * This is a corner case worth testing, since the property may legitimately be accessed before diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/dynamicmap/DynamicMapBaseIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/dynamicmap/DynamicMapBaseIT.java index 1f536bfa45c..8451709cbae 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/dynamicmap/DynamicMapBaseIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/dynamicmap/DynamicMapBaseIT.java @@ -38,14 +38,14 @@ import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.mapper.pojo.model.path.PojoModelPath; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test basic features when mapping a Hibernate ORM "dynamic-map" entity. @@ -53,20 +53,20 @@ * This test is rather simplistic because "dynamic-map" entity mapping is not fully supported in Hibernate Search yet. */ @SuppressWarnings("rawtypes") -public class DynamicMapBaseIT { +class DynamicMapBaseIT { private static final String INDEX1_NAME = "Index1Name"; private static final String INDEX2_NAME = "Index2Name"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void simple() { + void simple() { String hbmPath = "/DynamicMapBaseIT/simple.hbm.xml"; String entityTypeName = "Book"; @@ -134,7 +134,7 @@ public void simple() { @Test @TestForIssue(jiraKey = "HSEARCH-4656") - public void typeName_invalid() { + void typeName_invalid() { String hbmPath = "/DynamicMapBaseIT/simple.hbm.xml"; String entityTypeName = "Book"; @@ -159,7 +159,7 @@ public void typeName_invalid() { @Test @TestForIssue(jiraKey = "HSEARCH-3848") - public void searchObject() { + void searchObject() { String hbmPath = "/DynamicMapBaseIT/simple.hbm.xml"; String entityTypeName = "Book"; @@ -218,7 +218,7 @@ public void searchObject() { } @Test - public void massIndexing() { + void massIndexing() { String hbmPath = "/DynamicMapBaseIT/simple.hbm.xml"; String entityTypeName = "Book"; @@ -277,7 +277,7 @@ public void massIndexing() { } @Test - public void nonEntityIdDocumentId() { + void nonEntityIdDocumentId() { String hbmPath = "/DynamicMapBaseIT/simple.hbm.xml"; String entityTypeName = "Book"; @@ -337,7 +337,7 @@ public void nonEntityIdDocumentId() { } @Test - public void inheritance() { + void inheritance() { String hbmPath = "/DynamicMapBaseIT/inheritance.hbm.xml"; String entityATypeName = "A"; String entityA_BTypeName = "A_B"; @@ -425,7 +425,7 @@ public void inheritance() { } @Test - public void embedded_dynamicMap() { + void embedded_dynamicMap() { String hbmPath = "/DynamicMapBaseIT/embedded_dynamicmap.hbm.xml"; String bookTypeName = "Book"; String quoteTypeName = "Book.quote"; @@ -481,7 +481,7 @@ public void embedded_dynamicMap() { } @Test - public void embedded_class() { + void embedded_class() { String hbmPath = "/DynamicMapBaseIT/embedded_class.hbm.xml"; String bookTypeName = "Book"; @@ -536,7 +536,7 @@ public void embedded_class() { } @Test - public void embedded_class_list() { + void embedded_class_list() { String hbmPath = "/DynamicMapBaseIT/embedded_class_list.hbm.xml"; String bookTypeName = "Book"; @@ -603,7 +603,7 @@ public void embedded_class_list() { } @Test - public void basic_list() { + void basic_list() { String hbmPath = "/DynamicMapBaseIT/basic_list.hbm.xml"; String bookTypeName = "Book"; @@ -650,8 +650,8 @@ public void basic_list() { } @Test - @Ignore("toone associations are buggy in dynamic-map mode -- see https://hibernate.atlassian.net/browse/HHH-16100") - public void toOne() { + @Disabled("toone associations are buggy in dynamic-map mode -- see https://hibernate.atlassian.net/browse/HHH-16100") + void toOne() { String hbmPath = "/DynamicMapBaseIT/toone.hbm.xml"; String bookTypeName = "Book"; String quoteTypeName = "Quote"; @@ -710,7 +710,7 @@ public void toOne() { } @Test - public void onetomany_bag() { + void onetomany_bag() { String hbmPath = "/DynamicMapBaseIT/onetomany_bag.hbm.xml"; String bookTypeName = "Book"; String quoteTypeName = "Quote"; @@ -787,7 +787,7 @@ public void onetomany_bag() { } @Test - public void onetomany_list() { + void onetomany_list() { String hbmPath = "/DynamicMapBaseIT/onetomany_list.hbm.xml"; String bookTypeName = "Book"; String quoteTypeName = "Quote"; @@ -864,7 +864,7 @@ public void onetomany_list() { } @Test - public void onetomany_set() { + void onetomany_set() { String hbmPath = "/DynamicMapBaseIT/onetomany_set.hbm.xml"; String bookTypeName = "Book"; String quoteTypeName = "Quote"; @@ -941,7 +941,7 @@ public void onetomany_set() { } @Test - public void onetomany_map_key() { + void onetomany_map_key() { String hbmPath = "/DynamicMapBaseIT/onetomany_map_key.hbm.xml"; String bookTypeName = "Book"; String quoteTypeName = "Quote"; @@ -1020,7 +1020,7 @@ public void onetomany_map_key() { } @Test - public void onetomany_map_value() { + void onetomany_map_value() { String hbmPath = "/DynamicMapBaseIT/onetomany_map_value.hbm.xml"; String bookTypeName = "Book"; String quoteTypeName = "Quote"; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmQueryIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmQueryIT.java index db45b7ad3a9..660892c1353 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmQueryIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmQueryIT.java @@ -34,8 +34,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.util.common.SearchTimeoutException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -53,7 +53,7 @@ public class ToHibernateOrmQueryIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmScrollableResultsIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmScrollableResultsIT.java index ed9423b4fa1..4de6a9cbb0a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmScrollableResultsIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmScrollableResultsIT.java @@ -31,9 +31,9 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.SearchTimeoutException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubNextScrollWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubNextScrollWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendUtils; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -55,7 +55,7 @@ public class ToHibernateOrmScrollableResultsIT { private static final int DEFAULT_FETCH_SIZE = 100; @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmSessionIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmSessionIT.java index ee08a62018e..2d48a832d19 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmSessionIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToHibernateOrmSessionIT.java @@ -22,8 +22,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -40,7 +40,7 @@ public class ToHibernateOrmSessionIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToJpaEntityManagerIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToJpaEntityManagerIT.java index e14979dc8ef..beaa5423d28 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToJpaEntityManagerIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToJpaEntityManagerIT.java @@ -20,7 +20,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -37,7 +37,7 @@ public class ToJpaEntityManagerIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToJpaQueryIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToJpaQueryIT.java index 146bd23ddaa..0aba46119ed 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToJpaQueryIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToJpaQueryIT.java @@ -38,8 +38,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.util.common.SearchTimeoutException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -57,7 +57,7 @@ public class ToJpaQueryIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToSearchSessionFromSessionProxyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToSearchSessionFromSessionProxyIT.java index fef48a64957..c9b1c8aa26e 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToSearchSessionFromSessionProxyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/hibernateormapis/ToSearchSessionFromSessionProxyIT.java @@ -7,9 +7,8 @@ package org.hibernate.search.integrationtest.mapper.orm.hibernateormapis; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.runInTransaction; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import java.lang.reflect.Proxy; import java.util.concurrent.CompletableFuture; @@ -31,7 +30,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; @@ -59,7 +58,7 @@ public class ToSearchSessionFromSessionProxyIT { }; @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); @@ -90,7 +89,7 @@ public void testSessionWrapper() { ); try { SearchSession searchSession = Search.session( wrapped ); - assertNotNull( searchSession ); + assertThat( searchSession ).isNotNull(); assertThat( searchSession.toEntityManager() ).isSameAs( wrapped ); assertThat( searchSession.toOrmSession() ).isSameAs( wrapped ); } @@ -108,7 +107,7 @@ public void testThreadBoundSessionWrappingInTransaction() { try { runInTransaction( sessionFromFirstThread, ignored -> { SearchSession searchSessionFromFirstThread = Search.session( sessionFromFirstThread ); - assertNotNull( searchSessionFromFirstThread ); + assertThat( searchSessionFromFirstThread ).isNotNull(); assertThat( searchSessionFromFirstThread.toEntityManager() ).isSameAs( sessionFromFirstThread ); assertThat( searchSessionFromFirstThread.toOrmSession() ).isSameAs( sessionFromFirstThread ); ThreadPoolExecutor executorService = new ThreadPoolExecutor( @@ -120,7 +119,7 @@ public void testThreadBoundSessionWrappingInTransaction() { Session sessionFromOtherThread = setupHolder.sessionFactory().getCurrentSession(); assertThat( sessionFromOtherThread ).isNotSameAs( sessionFromFirstThread ); SearchSession searchSessionFromOtherThread = Search.session( sessionFromOtherThread ); - assertNotNull( searchSessionFromOtherThread ); + assertThat( searchSessionFromOtherThread ).isNotNull(); assertThat( searchSessionFromOtherThread.toEntityManager() ).isSameAs( sessionFromOtherThread ); assertThat( searchSessionFromOtherThread.toOrmSession() ).isSameAs( sessionFromOtherThread ); }, @@ -140,7 +139,7 @@ public void testThreadBoundSessionWrappingOutOfTransaction() { final Session sessionFromFirstThread = setupHolder.sessionFactory().getCurrentSession(); try { SearchSession searchSessionFromFirstThread = Search.session( sessionFromFirstThread ); - assertNotNull( searchSessionFromFirstThread ); + assertThat( searchSessionFromFirstThread ).isNotNull(); assertThat( searchSessionFromFirstThread.toEntityManager() ).isSameAs( sessionFromFirstThread ); assertThat( searchSessionFromFirstThread.toOrmSession() ).isSameAs( sessionFromFirstThread ); ThreadPoolExecutor executorService = new ThreadPoolExecutor( @@ -152,7 +151,7 @@ public void testThreadBoundSessionWrappingOutOfTransaction() { Session sessionFromOtherThread = setupHolder.sessionFactory().getCurrentSession(); assertThat( sessionFromOtherThread ).isNotSameAs( sessionFromFirstThread ); SearchSession searchSessionFromOtherThread = Search.session( sessionFromOtherThread ); - assertNotNull( searchSessionFromOtherThread ); + assertThat( searchSessionFromOtherThread ).isNotNull(); assertThat( searchSessionFromOtherThread.toEntityManager() ).isSameAs( sessionFromOtherThread ); assertThat( searchSessionFromOtherThread.toOrmSession() ).isSameAs( sessionFromOtherThread ); }, diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/SearchMappingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/SearchMappingIT.java index 8f239a2d938..765ae3ff81d 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/SearchMappingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/SearchMappingIT.java @@ -31,9 +31,10 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.reporting.EventContext; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.impl.StubBackend; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.impl.StubIndexManager; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -51,10 +52,10 @@ public class SearchMappingIT { private static final String BACKEND_2_NAME = "stubBackend2"; @ClassRule - public static BackendMock defaultBackendMock = new BackendMock(); + public static BackendMockTestRule defaultBackendMock = BackendMockTestRule.createGlobal(); @ClassRule - public static BackendMock backend2Mock = new BackendMock(); + public static BackendMockTestRule backend2Mock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/SearchMappingNoDefaultBackendIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/SearchMappingNoDefaultBackendIT.java index 1385db98fde..dc187bc9e3a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/SearchMappingNoDefaultBackendIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/SearchMappingNoDefaultBackendIT.java @@ -22,7 +22,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -39,10 +40,10 @@ public class SearchMappingNoDefaultBackendIT { private static final String BACKEND_2_NAME = "stubBackend2"; @ClassRule - public static BackendMock backend1Mock = new BackendMock(); + public static BackendMockTestRule backend1Mock = BackendMockTestRule.createGlobal(); @ClassRule - public static BackendMock backend2Mock = new BackendMock(); + public static BackendMockTestRule backend2Mock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/definition/AnnotationMappingDiscoveryIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/definition/AnnotationMappingDiscoveryIT.java index 803bb751815..6a7d560bbfd 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/definition/AnnotationMappingDiscoveryIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/definition/AnnotationMappingDiscoveryIT.java @@ -35,22 +35,22 @@ import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.ProgrammaticMappingConfigurationContext; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.mapper.pojo.model.PojoModelProperty; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class AnnotationMappingDiscoveryIT { +class AnnotationMappingDiscoveryIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void discoveryEnabled() { + void discoveryEnabled() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "annotationMappedEmbedded", b2 -> b2 /* @@ -96,7 +96,7 @@ public void discoveryEnabled() { } @Test - public void discoveryDisabled() { + void discoveryDisabled() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "annotationMappedEmbedded", b2 -> { /* diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/definition/HibernateOrmSearchMappingConfigurerIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/definition/HibernateOrmSearchMappingConfigurerIT.java index a433187b3e7..67697b535d8 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/definition/HibernateOrmSearchMappingConfigurerIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/mapping/definition/HibernateOrmSearchMappingConfigurerIT.java @@ -14,23 +14,23 @@ import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class HibernateOrmSearchMappingConfigurerIT { +class HibernateOrmSearchMappingConfigurerIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void none() { + void none() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "annotationMapped", String.class ) ); @@ -41,7 +41,7 @@ public void none() { } @Test - public void single() { + void single() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "annotationMapped", String.class ) .field( "nonAnnotationMapped1", String.class ) @@ -65,7 +65,7 @@ public void configure(HibernateOrmMappingConfigurationContext context) { @Test @TestForIssue(jiraKey = "HSEARCH-4594") - public void multiple() { + void multiple() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "annotationMapped", String.class ) .field( "nonAnnotationMapped1", String.class ) diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/AbstractMassIndexingErrorIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/AbstractMassIndexingErrorIT.java index cb0fc49db68..4841a75021b 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/AbstractMassIndexingErrorIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/AbstractMassIndexingErrorIT.java @@ -32,8 +32,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.ThreadSpy; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.ThreadSpy; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubIndexScaleWork; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; @@ -41,8 +41,8 @@ import org.hibernate.search.util.impl.test.annotation.TestForIssue; import org.hibernate.search.util.impl.test.reflect.RuntimeHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; import org.awaitility.Awaitility; @@ -56,14 +56,14 @@ public abstract class AbstractMassIndexingErrorIT { public static final String TITLE_3 = "Frankenstein"; public static final String AUTHOR_3 = "Mary Shelley"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule - public ThreadSpy threadSpy = new ThreadSpy(); + @RegisterExtension + public ThreadSpy threadSpy = ThreadSpy.create(); @Test @TestForIssue(jiraKey = { "HSEARCH-4218", "HSEARCH-4236" }) @@ -123,7 +123,7 @@ public void entityLoading() { } @Test - public void indexing() { + void indexing() { SessionFactory sessionFactory = setup(); String errorMessage = "Indexing error"; @@ -144,7 +144,7 @@ public void indexing() { } @Test - public void getId() { + void getId() { SessionFactory sessionFactory = setup(); String errorMessage = "getId error"; @@ -167,7 +167,7 @@ public void getId() { } @Test - public void getTitle() { + void getTitle() { SessionFactory sessionFactory = setup(); String errorMessage = "getTitle error"; @@ -189,7 +189,7 @@ public void getTitle() { } @Test - public void dropAndCreateSchema_exception() { + void dropAndCreateSchema_exception() { SessionFactory sessionFactory = setup(); String errorMessage = "DROP_AND_CREATE error"; @@ -208,7 +208,7 @@ public void dropAndCreateSchema_exception() { } @Test - public void purge() { + void purge() { SessionFactory sessionFactory = setup(); String errorMessage = "PURGE error"; @@ -227,7 +227,7 @@ public void purge() { } @Test - public void mergeSegmentsBefore() { + void mergeSegmentsBefore() { SessionFactory sessionFactory = setup(); String errorMessage = "MERGE_SEGMENTS error"; @@ -247,7 +247,7 @@ public void mergeSegmentsBefore() { } @Test - public void mergeSegmentsAfter() { + void mergeSegmentsAfter() { SessionFactory sessionFactory = setup(); String errorMessage = "MERGE_SEGMENTS error"; @@ -270,7 +270,7 @@ public void mergeSegmentsAfter() { } @Test - public void flush() { + void flush() { SessionFactory sessionFactory = setup(); String errorMessage = "FLUSH error"; @@ -292,7 +292,7 @@ public void flush() { } @Test - public void refresh() { + void refresh() { SessionFactory sessionFactory = setup(); String errorMessage = "REFRESH error"; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/AbstractMassIndexingFailureIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/AbstractMassIndexingFailureIT.java index 33cf4cf2c7a..96e17725039 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/AbstractMassIndexingFailureIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/AbstractMassIndexingFailureIT.java @@ -36,9 +36,9 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.ThreadSpy; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.ThreadSpy; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubIndexScaleWork; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; @@ -46,8 +46,8 @@ import org.hibernate.search.util.impl.test.annotation.TestForIssue; import org.hibernate.search.util.impl.test.reflect.RuntimeHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; import org.awaitility.Awaitility; @@ -64,14 +64,14 @@ public abstract class AbstractMassIndexingFailureIT { public static final String TITLE_3 = "Frankenstein"; public static final String AUTHOR_3 = "Mary Shelley"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule - public ThreadSpy threadSpy = new ThreadSpy(); + @RegisterExtension + public ThreadSpy threadSpy = ThreadSpy.create(); public int getDefaultFailureFloodingThreshold() { return DEFAULT_FAILURE_FLOODING_THRESHOLD; @@ -192,7 +192,7 @@ public void entityLoading(Optional failureFloodingThreshold) { } @Test - public void indexing() { + void indexing() { SessionFactory sessionFactory = setup(); String entityName = Book.NAME; @@ -230,7 +230,7 @@ public void indexing() { } @Test - public void getId() { + void getId() { SessionFactory sessionFactory = setup(); String entityName = Book.NAME; @@ -271,7 +271,7 @@ public void getId() { } @Test - public void getTitle() { + void getTitle() { SessionFactory sessionFactory = setup(); String entityName = Book.NAME; @@ -312,7 +312,7 @@ public void getTitle() { } @Test - public void dropAndCreateSchema_exception() { + void dropAndCreateSchema_exception() { SessionFactory sessionFactory = setup(); String exceptionMessage = "DROP_AND_CREATE failure"; @@ -334,7 +334,7 @@ public void dropAndCreateSchema_exception() { } @Test - public void purge() { + void purge() { SessionFactory sessionFactory = setup(); String exceptionMessage = "PURGE failure"; @@ -360,7 +360,7 @@ public void purge() { } @Test - public void mergeSegmentsBefore() { + void mergeSegmentsBefore() { SessionFactory sessionFactory = setup(); String exceptionMessage = "MERGE_SEGMENTS failure"; @@ -387,7 +387,7 @@ public void mergeSegmentsBefore() { } @Test - public void mergeSegmentsAfter() { + void mergeSegmentsAfter() { SessionFactory sessionFactory = setup(); String exceptionMessage = "MERGE_SEGMENTS failure"; @@ -417,7 +417,7 @@ public void mergeSegmentsAfter() { } @Test - public void flush() { + void flush() { SessionFactory sessionFactory = setup(); String exceptionMessage = "FLUSH failure"; @@ -446,7 +446,7 @@ public void flush() { } @Test - public void refresh() { + void refresh() { SessionFactory sessionFactory = setup(); String exceptionMessage = "REFRESH failure"; @@ -476,7 +476,7 @@ public void refresh() { } @Test - public void indexingAndFlush() { + void indexingAndFlush() { SessionFactory sessionFactory = setup(); String entityName = Book.NAME; @@ -524,7 +524,7 @@ public void indexingAndFlush() { } @Test - public void indexingAndRefresh() { + void indexingAndRefresh() { SessionFactory sessionFactory = setup(); String entityName = Book.NAME; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingBaseIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingBaseIT.java index 00956c7e228..d6600c95cf9 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingBaseIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingBaseIT.java @@ -30,8 +30,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -67,7 +67,7 @@ public static TenancyMode[] params() { public static final String AUTHOR_4 = "J. R. R. Tolkien"; @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingCachingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingCachingIT.java index 9db36d65ba7..d5ac6b24032 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingCachingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingCachingIT.java @@ -24,7 +24,7 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -42,7 +42,7 @@ public class MassIndexingCachingIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingComplexHierarchyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingComplexHierarchyIT.java index 316db64c460..ed7b25c0f02 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingComplexHierarchyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingComplexHierarchyIT.java @@ -19,7 +19,7 @@ import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -36,7 +36,7 @@ public class MassIndexingComplexHierarchyIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingConditionalExpressionsIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingConditionalExpressionsIT.java index 34f90f657c5..d95c4f73670 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingConditionalExpressionsIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingConditionalExpressionsIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.orm.massindexing; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.fail; import java.time.Instant; @@ -25,7 +25,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -54,7 +54,7 @@ public class MassIndexingConditionalExpressionsIT { private static final String KEYWORD_B_2 = "b-2"; @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingEmbeddedIdIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingEmbeddedIdIT.java index 45f84137360..3cae5127934 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingEmbeddedIdIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingEmbeddedIdIT.java @@ -31,17 +31,17 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test mass indexing of an entity type using an {@link EmbeddedId}. */ -public class MassIndexingEmbeddedIdIT { +class MassIndexingEmbeddedIdIT { public static final String TITLE_1 = "Oliver Twist"; public static final String AUTHOR_1 = "Charles Dickens"; @@ -50,10 +50,10 @@ public class MassIndexingEmbeddedIdIT { public static final String TITLE_3 = "Frankenstein"; public static final String AUTHOR_3 = "Mary Shelley"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; @@ -61,8 +61,8 @@ public class MassIndexingEmbeddedIdIT { private Book book2; private Book book3; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Book.INDEX ); sessionFactory = ormSetupHelper.start() @@ -75,7 +75,7 @@ public void setup() { } @Test - public void defaultMassIndexerStartAndWait() { + void defaultMassIndexerStartAndWait() { with( sessionFactory ).runNoTransaction( session -> { SearchSession searchSession = Search.session( session ); MassIndexer indexer = searchSession.massIndexer(); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorCustomBackgroundFailureHandlerIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorCustomBackgroundFailureHandlerIT.java index 8b8a5f45b36..5549f7b66db 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorCustomBackgroundFailureHandlerIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorCustomBackgroundFailureHandlerIT.java @@ -12,18 +12,17 @@ import org.hibernate.search.engine.reporting.FailureHandler; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; -import org.junit.Rule; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) public class MassIndexingErrorCustomBackgroundFailureHandlerIT extends AbstractMassIndexingErrorIT { - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private FailureHandler failureHandler; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorCustomMassIndexingFailureHandlerIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorCustomMassIndexingFailureHandlerIT.java index 6119d6d733f..7b86281fa3c 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorCustomMassIndexingFailureHandlerIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorCustomMassIndexingFailureHandlerIT.java @@ -12,18 +12,17 @@ import org.hibernate.search.engine.reporting.FailureHandler; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; -import org.junit.Rule; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) public class MassIndexingErrorCustomMassIndexingFailureHandlerIT extends AbstractMassIndexingErrorIT { - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private MassIndexingFailureHandler failureHandler; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorDefaultBackgroundFailureHandlerIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorDefaultBackgroundFailureHandlerIT.java index 4a8daad4312..74eea09dd5a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorDefaultBackgroundFailureHandlerIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingErrorDefaultBackgroundFailureHandlerIT.java @@ -8,15 +8,15 @@ import org.hibernate.search.engine.reporting.FailureHandler; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; public class MassIndexingErrorDefaultBackgroundFailureHandlerIT extends AbstractMassIndexingErrorIT { - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Override diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureCustomBackgroundFailureHandlerIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureCustomBackgroundFailureHandlerIT.java index 4c319192efb..9e138316565 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureCustomBackgroundFailureHandlerIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureCustomBackgroundFailureHandlerIT.java @@ -22,24 +22,23 @@ import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.assertj.core.api.InstanceOfAssertFactories; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) public class MassIndexingFailureCustomBackgroundFailureHandlerIT extends AbstractMassIndexingFailureIT { private static final int DEFAULT_FAILURE_FLOODING_THRESHOLD = 100; - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private FailureHandler failureHandler; @@ -215,8 +214,8 @@ protected void assertEntityIndexingAndMassIndexerOperationFailureHandling(String .isEqualTo( failingMassIndexerOperationAsString ); } - @Before - public void setUp() { + @BeforeEach + void setUp() { lenient().when( failureHandler.failureFloodingThreshold() ).thenReturn( (long) getDefaultFailureFloodingThreshold() ); } diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureCustomMassIndexingFailureHandlerIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureCustomMassIndexingFailureHandlerIT.java index f6400b35ded..6e4ab6ce5ae 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureCustomMassIndexingFailureHandlerIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureCustomMassIndexingFailureHandlerIT.java @@ -22,23 +22,23 @@ import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.assertj.core.api.InstanceOfAssertFactories; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) public class MassIndexingFailureCustomMassIndexingFailureHandlerIT extends AbstractMassIndexingFailureIT { private static final int DEFAULT_FAILURE_FLOODING_THRESHOLD = 62; - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); @Mock private MassIndexingFailureHandler failureHandler; @@ -216,8 +216,8 @@ protected void assertEntityIndexingAndMassIndexerOperationFailureHandling(String .isEqualTo( failingMassIndexerOperationAsString ); } - @Before - public void setUp() { + @BeforeEach + void setUp() { lenient().when( failureHandler.failureFloodingThreshold() ).thenReturn( (long) getDefaultFailureFloodingThreshold() ); } diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureDefaultBackgroundFailureHandlerIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureDefaultBackgroundFailureHandlerIT.java index 4137db7534b..4c137c861e0 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureDefaultBackgroundFailureHandlerIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingFailureDefaultBackgroundFailureHandlerIT.java @@ -11,15 +11,15 @@ import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.test.ExceptionMatcherBuilder; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; public class MassIndexingFailureDefaultBackgroundFailureHandlerIT extends AbstractMassIndexingFailureIT { - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Override diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingIdClassIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingIdClassIT.java index 4db5fc87e0f..43bfb772f37 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingIdClassIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingIdClassIT.java @@ -24,7 +24,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -39,7 +39,7 @@ public class MassIndexingIdClassIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingInterruptionIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingInterruptionIT.java index d5086c94cda..7424fcce43a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingInterruptionIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingInterruptionIT.java @@ -28,13 +28,13 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.ThreadSpy; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.ThreadSpy; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; import org.awaitility.Awaitility; @@ -42,24 +42,24 @@ /** * Test interruption of a currently executing {@link MassIndexer}. */ -public class MassIndexingInterruptionIT { +class MassIndexingInterruptionIT { public static final String TITLE_1 = "Oliver Twist"; public static final String AUTHOR_1 = "Charles Dickens"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule - public ThreadSpy threadSpy = new ThreadSpy(); + @RegisterExtension + public ThreadSpy threadSpy = ThreadSpy.create(); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Book.INDEX ); sessionFactory = ormSetupHelper.start() @@ -73,7 +73,7 @@ public void setup() { } @Test - public void interrupt_mainThread() { + void interrupt_mainThread() { int expectedThreadCount = 1 // Workspace + 1 // ID loading + 1; // Entity loading @@ -118,7 +118,7 @@ public void interrupt_mainThread() { } @Test - public void interrupt_entityLoading() { + void interrupt_entityLoading() { int expectedThreadCount = 1 // Workspace + 1 // ID loading + 1; // Entity loading @@ -159,7 +159,7 @@ public void interrupt_entityLoading() { } @Test - public void cancel() { + void cancel() { int expectedThreadCount = 1 // Coordinator + 1 // Workspace + 1 // ID loading diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingMonitorIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingMonitorIT.java index d1d7a214015..969821bbb2a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingMonitorIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingMonitorIT.java @@ -28,14 +28,14 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingMonitor; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MassIndexingMonitorIT { +class MassIndexingMonitorIT { public static final String TITLE_1 = "Oliver Twist"; public static final String AUTHOR_1 = "Charles Dickens"; @@ -44,17 +44,17 @@ public class MassIndexingMonitorIT { public static final String TITLE_3 = "Frankenstein"; public static final String AUTHOR_3 = "Mary Shelley"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - @Rule - public StaticCounters staticCounters = new StaticCounters(); + @RegisterExtension + public StaticCounters staticCounters = StaticCounters.create(); @Test - public void simple() { + void simple() { SessionFactory sessionFactory = setup( null ); with( sessionFactory ).runNoTransaction( session -> { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingNonEntityIdDocumentIdIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingNonEntityIdDocumentIdIT.java index ad2831575f6..f531ac14365 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingNonEntityIdDocumentIdIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingNonEntityIdDocumentIdIT.java @@ -23,18 +23,18 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test mass indexing of an entity type whose document ID is not the entity ID. */ -public class MassIndexingNonEntityIdDocumentIdIT { +class MassIndexingNonEntityIdDocumentIdIT { private static final String TITLE_1 = "Oliver Twist"; private static final String AUTHOR_1 = "Charles Dickens"; @@ -43,16 +43,16 @@ public class MassIndexingNonEntityIdDocumentIdIT { private static final String TITLE_3 = "Frankenstein"; private static final String AUTHOR_3 = "Mary Shelley"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Book.INDEX ); sessionFactory = ormSetupHelper.start() @@ -66,7 +66,7 @@ public void setup() { @Test @TestForIssue(jiraKey = "HSEARCH-3203") - public void defaultMassIndexerStartAndWait() { + void defaultMassIndexerStartAndWait() { with( sessionFactory ).runNoTransaction( session -> { SearchSession searchSession = Search.session( session ); MassIndexer indexer = searchSession.massIndexer(); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingPrimitiveIdIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingPrimitiveIdIT.java index 9c8faf7f057..d988ce33e72 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingPrimitiveIdIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/massindexing/MassIndexingPrimitiveIdIT.java @@ -21,27 +21,27 @@ import org.hibernate.search.mapper.orm.massindexing.MassIndexer; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-3529") -public class MassIndexingPrimitiveIdIT { +class MassIndexingPrimitiveIdIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( EntityWithPrimitiveId.INDEX ); sessionFactory = ormSetupHelper.start() @@ -54,7 +54,7 @@ public void setup() { } @Test - public void entityWithPrimitiveId() { + void entityWithPrimitiveId() { with( sessionFactory ).runNoTransaction( session -> { SearchSession searchSession = Search.session( session ); MassIndexer indexer = searchSession.massIndexer(); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/AnnotationMappingAccessTypeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/AnnotationMappingAccessTypeIT.java index da655eeb957..fc357531934 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/AnnotationMappingAccessTypeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/AnnotationMappingAccessTypeIT.java @@ -6,8 +6,8 @@ */ package org.hibernate.search.integrationtest.mapper.orm.model; +import static org.assertj.core.api.Assertions.fail; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assert.fail; import java.io.Serializable; @@ -29,12 +29,12 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Integration tests checking that we get the expected access type for properties when using annotation mapping. @@ -44,18 +44,18 @@ * Note that more thorough testing is performed in {@code HibernateOrmBootstrapIntrospectorAccessTypeTest}, * including tests of access type on an embeddable that is only ever mentioned in an element collection. */ -public class AnnotationMappingAccessTypeIT { +class AnnotationMappingAccessTypeIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "fieldWithNonDefaultFieldAccess", String.class ) .field( "fieldWithDefaultFieldAccess", String.class ) @@ -87,7 +87,7 @@ public void setup() { } @Test - public void index() { + void index() { with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); entity1.id = 1; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BackRefPropertyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BackRefPropertyIT.java index f99343ff261..a6dba0c00f9 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BackRefPropertyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BackRefPropertyIT.java @@ -28,12 +28,12 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ObjectPath; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Check that we correctly populate the metamodel when ORM generates a {@link org.hibernate.mapping.Backref} @@ -42,16 +42,16 @@ * whose referenced column is not the entity ID. */ @TestForIssue(jiraKey = "HSEARCH-4156") -public class BackRefPropertyIT { +class BackRefPropertyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void test() { + void test() { backendMock.expectSchema( IndexedEntity.NAME, b -> b .objectField( "contained", b2 -> b2 .field( "text", String.class, b3 -> {} ) ) ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BindingUsingPropertyMarkerAccessIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BindingUsingPropertyMarkerAccessIT.java index f24be08d012..59a92f359fe 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BindingUsingPropertyMarkerAccessIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BindingUsingPropertyMarkerAccessIT.java @@ -8,6 +8,9 @@ import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; +import java.util.Arrays; +import java.util.List; + import jakarta.persistence.Entity; import jakarta.persistence.Id; @@ -20,15 +23,14 @@ import org.hibernate.search.mapper.pojo.bridge.builtin.annotation.Longitude; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test that a binding using markers to retrieve and access properties @@ -39,41 +41,38 @@ * * @param The entity class under test. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = { "HSEARCH-2759", "HSEARCH-2847" }) @SuppressWarnings("unused") public class BindingUsingPropertyMarkerAccessIT { private static final String INDEX_NAME = "IndexedEntity"; - @Parameterized.Parameters(name = "{0}") - public static Object[][] parameters() { - return new Object[][] { - { PrivateFieldAccessEntity.PRIMITIVES }, - { ProtectedFieldAccessEntity.PRIMITIVES }, - { PublicFieldAccessEntity.PRIMITIVES }, - { PublicMethodAccessEntity.PRIMITIVES }, - { ProtectedMethodAccessEntity.PRIMITIVES }, - { PrivateMethodAccessEntity.PRIMITIVES } - }; + public static List params() { + return Arrays.asList( + Arguments.of( PrivateFieldAccessEntity.PRIMITIVES ), + Arguments.of( ProtectedFieldAccessEntity.PRIMITIVES ), + Arguments.of( PublicFieldAccessEntity.PRIMITIVES ), + Arguments.of( PublicMethodAccessEntity.PRIMITIVES ), + Arguments.of( ProtectedMethodAccessEntity.PRIMITIVES ), + Arguments.of( PrivateMethodAccessEntity.PRIMITIVES ) + ); } - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); - private ModelPrimitives modelPrimitives; - private SessionFactory sessionFactory; - public BindingUsingPropertyMarkerAccessIT(ModelPrimitives modelPrimitives) { - this.modelPrimitives = modelPrimitives; - } - - @Before - public void setup() { + /** + * This just tests that Hibernate Search manages to extract data from the entity. + * This used to fail when the only way to extract latitude was a private field, for example. + */ + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void indexing(ModelPrimitives modelPrimitives) { backendMock.expectSchema( INDEX_NAME, b -> b .field( "location", GeoPoint.class, b2 -> b2.projectable( Projectable.DEFAULT ).sortable( Sortable.DEFAULT ) ) @@ -81,14 +80,6 @@ public void setup() { sessionFactory = ormSetupHelper.start() .setup( modelPrimitives.getModelClass() ); backendMock.verifyExpectationsMet(); - } - - /** - * This just tests that Hibernate Search manages to extract data from the entity. - * This used to fail when the only way to extract latitude was a private field, for example. - */ - @Test - public void indexing() { with( sessionFactory ).runInTransaction( session -> { TIndexed entity1 = modelPrimitives.create( 1, 42.0, 42.0 ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BytecodeEnhancementIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BytecodeEnhancementIT.java index 4410bfc0919..d2e94f0290f 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BytecodeEnhancementIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/BytecodeEnhancementIT.java @@ -8,7 +8,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.ManagedAssert.assertThatManaged; -import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; import java.lang.reflect.Method; import java.util.ArrayList; @@ -31,7 +30,6 @@ import jakarta.persistence.OneToMany; import jakarta.persistence.Transient; -import org.hibernate.SessionFactory; import org.hibernate.annotations.LazyGroup; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; @@ -39,30 +37,33 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner; -import org.junit.Before; +import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.MethodRule; import org.junit.runner.RunWith; @RunWith(BytecodeEnhancerRunner.class) public class BytecodeEnhancementIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @ClassRule + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); - @Rule - public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); + @ClassRule + public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); - private SessionFactory sessionFactory; + @Rule + public MethodRule setupHolderMethodRule = setupHolder.methodRule(); - @Before - public void setup() { + @ReusableOrmSetupHolder.Setup + public void setup(OrmSetupHelper.SetupContext setupContext) { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "mappedSuperClassText", String.class ) .field( "entitySuperClassText", String.class ) @@ -84,21 +85,20 @@ public void setup() { .field( "transientText", String.class ) ); - sessionFactory = ormSetupHelper.start() + setupContext /* * This is necessary in order for the BytecodeEnhancerRunner to work correctly. * Otherwise classes can be successfully loaded from the application classloader * and the "bytecode-enhancing" TCCL won't even be tried. */ .withTcclLookupPrecedenceBefore() - .setup( + .withAnnotatedTypes( IndexedMappedSuperClass.class, IndexedEntitySuperClass.class, IndexedEntity.class, ContainedEntity.class, ContainedEmbeddable.class ); - backendMock.verifyExpectationsMet(); } @Test @@ -111,7 +111,7 @@ public void testBytecodeEnhancementWorked() { @Test @TestForIssue(jiraKey = "HSEARCH-3581") public void test() { - with( sessionFactory ).runInTransaction( session -> { + setupHolder.runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); // This cast is necessary to work around https://hibernate.atlassian.net/browse/HHH-14006 ( (IndexedEntitySuperClass) entity1 ).id = 1; @@ -176,7 +176,7 @@ public void test() { AtomicReference entityFromTransaction = new AtomicReference<>(); - with( sessionFactory ).runInTransaction( session -> { + setupHolder.runInTransaction( session -> { IndexedEntity entity = session.getReference( IndexedEntity.class, 1 ); entityFromTransaction.set( entity ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/DefaultDecimalScaleMappingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/DefaultDecimalScaleMappingIT.java index 2ea8478ba2b..5a3ba300fb3 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/DefaultDecimalScaleMappingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/DefaultDecimalScaleMappingIT.java @@ -17,24 +17,24 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ScaledNumberField; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DefaultDecimalScaleMappingIT { +class DefaultDecimalScaleMappingIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void mapping() { + void mapping() { backendMock.expectSchema( INDEX_NAME, b -> b .field( "scaled", BigDecimal.class, f -> f.defaultDecimalScale( 7 ) ) .field( "unscaled", BigDecimal.class, f -> f.defaultDecimalScale( 0 ) ) @@ -52,7 +52,7 @@ public void mapping() { } @Test - public void bigIntegerIdMapping() { + void bigIntegerIdMapping() { backendMock.expectSchema( IdWithScale.NAME, b -> b .field( "id", BigInteger.class, f -> f.defaultDecimalScale( 0 ) ) .field( "other", BigInteger.class, f -> f.defaultDecimalScale( 0 ) ) @@ -64,7 +64,7 @@ public void bigIntegerIdMapping() { } @Test - public void bigDecimalIdMapping() { + void bigDecimalIdMapping() { backendMock.expectSchema( DecimalIdWithScale.NAME, b -> b .field( "id", BigDecimal.class, f -> f.defaultDecimalScale( 2 ) ) ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/FilteredAssociationIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/FilteredAssociationIT.java index e866275d4c4..13a1546c5b7 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/FilteredAssociationIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/FilteredAssociationIT.java @@ -26,25 +26,25 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ObjectPath; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Check that we can use @IndexedEmbedded on an association "filtered" from another. */ -public class FilteredAssociationIT { +class FilteredAssociationIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void test() { + void test() { backendMock.expectSchema( IndexedEntity.NAME, b -> b .objectField( "contained", b2 -> b2 .multiValued( true ) diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/GenericPropertyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/GenericPropertyIT.java index 91fa3b5f362..52c3658c610 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/GenericPropertyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/GenericPropertyIT.java @@ -24,25 +24,25 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class GenericPropertyIT { +class GenericPropertyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "genericProperty", b2 -> b2 /* @@ -64,7 +64,7 @@ public void setup() { } @Test - public void index() { + void index() { with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); entity1.setId( 1 ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/IdClassIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/IdClassIT.java index 5fc71baa6af..4447995ae60 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/IdClassIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/IdClassIT.java @@ -20,28 +20,28 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests behavior when an entity uses {@link jakarta.persistence.IdClass}, */ -public class IdClassIT { +class IdClassIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); // This used to fail with an NPE at bootstrap @Test @TestForIssue(jiraKey = "HSEARCH-3874") - public void idClass_indexed() { + void idClass_indexed() { assertThatThrownBy( () -> ormSetupHelper.start().setup( IdClassIndexed.class ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -56,7 +56,7 @@ public void idClass_indexed() { // This used to fail with an NPE at bootstrap @Test @TestForIssue(jiraKey = "HSEARCH-3874") - public void idClass_nonIndexed() { + void idClass_nonIndexed() { backendMock.expectAnySchema( NonIdClassIndexed.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() @@ -77,7 +77,7 @@ public void idClass_nonIndexed() { @Test @TestForIssue(jiraKey = "HSEARCH-4025") - public void idClass_indexed_WithDocumentId() { + void idClass_indexed_WithDocumentId() { backendMock.expectAnySchema( IdClassIndexedWithDocumentId.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/IdDerivedFromAssociationIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/IdDerivedFromAssociationIT.java index df1fca3548e..1dc87090aca 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/IdDerivedFromAssociationIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/IdDerivedFromAssociationIT.java @@ -22,29 +22,29 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests behavior when an entity binds a {@code @OneToOne} association as its {@code @Id}. */ -public class IdDerivedFromAssociationIT { +class IdDerivedFromAssociationIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); // This is not currently supported, so we expect a failure at bootstrap, // with an appropriate error message giving at least a hint of how to solve the problem. @Test @TestForIssue(jiraKey = "HSEARCH-4352") - public void indexed_withoutDocumentId() { + void indexed_withoutDocumentId() { assertThatThrownBy( () -> ormSetupHelper.start().setup( NonIndexedBaseForIndexedDerived.class, IndexedDerived.class ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -60,7 +60,7 @@ public void indexed_withoutDocumentId() { // even though the class with a derived ID was not indexed. @Test @TestForIssue(jiraKey = "HSEARCH-4352") - public void nonIndexed() { + void nonIndexed() { backendMock.expectAnySchema( IndexedBaseForNonIndexedDerived.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() @@ -82,7 +82,7 @@ public void nonIndexed() { @Test @TestForIssue(jiraKey = "HSEARCH-4352") - public void indexed_withDocumentId() { + void indexed_withDocumentId() { backendMock.expectAnySchema( IndexedDerivedWithDocumentId.NAME ); SessionFactory sessionFactory = ormSetupHelper.start() diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/JpaIdAsDocumentIdIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/JpaIdAsDocumentIdIT.java index 71615cd90f3..fdcddf8386c 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/JpaIdAsDocumentIdIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/JpaIdAsDocumentIdIT.java @@ -22,25 +22,25 @@ import org.hibernate.search.engine.backend.types.Searchable; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Check that the JPA @Id is correctly used as the default @DocumentId. */ -public class JpaIdAsDocumentIdIT { +class JpaIdAsDocumentIdIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void test() { + void test() { backendMock.expectSchema( IndexedEntity.NAME, b -> b .objectField( "contained", b2 -> b2 .multiValued( true ) diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/MappedSuperclassIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/MappedSuperclassIT.java index ed1cf7c5b83..8eba34ea92c 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/MappedSuperclassIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/MappedSuperclassIT.java @@ -18,29 +18,29 @@ import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.ProgrammaticMappingConfigurationContext; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-1108") -public class MappedSuperclassIT { +class MappedSuperclassIT { private static final String INDEX_NAME = "IndexedEntity"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( INDEX_NAME, b -> b.field( "text", String.class, f -> f.analyzerName( AnalyzerNames.DEFAULT ) ) ); @@ -57,7 +57,7 @@ public void setup() { } @Test - public void index() { + void index() { with( sessionFactory ).runInTransaction( session -> { IndexedEntity indexedPojo = new IndexedEntity( 1, "Using some text here" ); session.persist( indexedPojo ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/ProgrammaticMappingAccessTypeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/ProgrammaticMappingAccessTypeIT.java index 3a72fc3b72d..70ffddb324e 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/ProgrammaticMappingAccessTypeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/ProgrammaticMappingAccessTypeIT.java @@ -6,8 +6,8 @@ */ package org.hibernate.search.integrationtest.mapper.orm.model; +import static org.assertj.core.api.Assertions.fail; import static org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.with; -import static org.junit.Assert.fail; import java.io.Serializable; @@ -31,12 +31,12 @@ import org.hibernate.search.mapper.orm.mapping.HibernateOrmSearchMappingConfigurer; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.ProgrammaticMappingConfigurationContext; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Integration tests checking that we get the expected access type for properties when using programmatic mapping. @@ -46,18 +46,18 @@ * Note that more thorough testing is performed in {@code HibernateOrmBootstrapIntrospectorAccessTypeTest}, * including tests of access type on an embeddable that is only ever mentioned in an element collection. */ -public class ProgrammaticMappingAccessTypeIT { +class ProgrammaticMappingAccessTypeIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "fieldWithNonDefaultFieldAccess", String.class ) .field( "fieldWithDefaultFieldAccess", String.class ) @@ -90,7 +90,7 @@ public void setup() { } @Test - public void index() { + void index() { with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); entity1.id = 1; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/PropertyInheritanceIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/PropertyInheritanceIT.java index f950f58e745..af81070bb29 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/PropertyInheritanceIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/PropertyInheritanceIT.java @@ -20,25 +20,25 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class PropertyInheritanceIT { +class PropertyInheritanceIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "parentDeclaredProperty", String.class ) .field( "childDeclaredProperty", String.class ) @@ -58,7 +58,7 @@ public void setup() { } @Test - public void index() { + void index() { with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); entity1.setId( 1 ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/ProxyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/ProxyIT.java index fcd6393cbea..58cbcc39287 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/ProxyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/ProxyIT.java @@ -19,26 +19,26 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProxyIT { +class ProxyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( EntityWithPropertyAccessTypeForId.INDEX, b -> b .field( "text", String.class ) ); @@ -59,7 +59,7 @@ public void setup() { */ @Test @TestForIssue(jiraKey = "HSEARCH-383") - public void proxyAccess() { + void proxyAccess() { with( sessionFactory ).runInTransaction( session -> { EntityWithPropertyAccessTypeForId entity1 = new EntityWithPropertyAccessTypeForId(); entity1.id = 1; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/SyntheticPropertyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/SyntheticPropertyIT.java index 143641afb59..01800536f1a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/SyntheticPropertyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/SyntheticPropertyIT.java @@ -25,12 +25,12 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Check that we correctly populate the metamodel when ORM generates a {@link org.hibernate.mapping.SyntheticProperty}, @@ -38,16 +38,16 @@ * (and, in ORM 6.2+, there are at least two referenced columns). */ @TestForIssue(jiraKey = { "HSEARCH-4156", "HSEARCH-4733" }) -public class SyntheticPropertyIT { +class SyntheticPropertyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void test() { + void test() { backendMock.expectSchema( IndexedEntity.NAME, b -> b .objectField( "contained", b2 -> b2 .field( "ref1", String.class, b3 -> {} ) diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/TransientPropertyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/TransientPropertyIT.java index c550b268874..61b7737a9eb 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/TransientPropertyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/model/TransientPropertyIT.java @@ -28,23 +28,23 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ObjectPath; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyBinding; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class TransientPropertyIT { +class TransientPropertyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void withoutDerivedFrom() { + void withoutDerivedFrom() { assertThatThrownBy( () -> ormSetupHelper.start().setup( EntityWithoutDerivedFrom.class ) ) @@ -59,7 +59,7 @@ public void withoutDerivedFrom() { } @Test - public void withDerivedFrom() { + void withDerivedFrom() { backendMock.expectSchema( EntityWithDerivedFrom.INDEX, b -> b .field( "APlusB", Integer.class ) ); @@ -108,7 +108,7 @@ public void withDerivedFrom() { } @Test - public void withDerivedFromAndBridge() { + void withDerivedFromAndBridge() { backendMock.expectSchema( EntityWithDerivedFromAndBridge.INDEX, b -> b .field( "APlusB", Integer.class ) ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/multitenancy/DatabaseMultitenancyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/multitenancy/DatabaseMultitenancyIT.java index 7ad811e95e7..4bff40a6648 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/multitenancy/DatabaseMultitenancyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/multitenancy/DatabaseMultitenancyIT.java @@ -18,24 +18,24 @@ import org.hibernate.search.engine.common.EntityReference; import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.mapper.orm.Search; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.PortedFromSearch5; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4034") @PortedFromSearch5(original = "org.hibernate.search.test.batchindexing.DatabaseMultitenancyTest") -public class DatabaseMultitenancyIT { +class DatabaseMultitenancyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); /** @@ -62,8 +62,8 @@ public class DatabaseMultitenancyIT { private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( Clock.INDEX, b -> b.field( "brand", String.class ) ); sessionFactory = ormSetupHelper .start() @@ -77,25 +77,25 @@ public void setup() { } @Test - public void shouldOnlyFindMetamecModels() { + void shouldOnlyFindMetamecModels() { List list = searchAll( METAMEC_TID, METAMEC_MODELS ); assertThat( list ).containsExactlyInAnyOrder( METAMEC_MODELS ); } @Test - public void shouldOnlyFindGeochronModels() { + void shouldOnlyFindGeochronModels() { List list = searchAll( GEOCHRON_TID, GEOCHRON_MODELS ); assertThat( list ).containsExactlyInAnyOrder( GEOCHRON_MODELS ); } @Test - public void shouldMatchOnlyElementsFromOneTenant() { + void shouldMatchOnlyElementsFromOneTenant() { List list = searchModel( "model", GEOCHRON_TID, GEOCHRON_MODELS ); assertThat( list ).containsExactlyInAnyOrder( GEOCHRON_MODELS ); } @Test - public void searchReferences() { + void searchReferences() { assertThat( searchReferences( GEOCHRON_TID, GEOCHRON_MODELS ) ).hasSize( GEOCHRON_MODELS.length ); } diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/AbstractSearchSchemaManagerSimpleOperationIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/AbstractSearchSchemaManagerSimpleOperationIT.java index 315c0947759..4148d898abf 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/AbstractSearchSchemaManagerSimpleOperationIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/AbstractSearchSchemaManagerSimpleOperationIT.java @@ -19,9 +19,9 @@ import org.hibernate.search.mapper.orm.schema.management.SearchSchemaManager; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -33,7 +33,7 @@ public abstract class AbstractSearchSchemaManagerSimpleOperationIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateIfMissingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateIfMissingIT.java index 2a5c38554b7..5665d0bd215 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateIfMissingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateIfMissingIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.manager; import org.hibernate.search.mapper.orm.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SearchSchemaManagerCreateIfMissingIT extends AbstractSearchSchemaManagerSimpleOperationIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateOrUpdateIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateOrUpdateIT.java index 44637a56fc8..d6140ea9301 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateOrUpdateIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateOrUpdateIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.manager; import org.hibernate.search.mapper.orm.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SearchSchemaManagerCreateOrUpdateIT extends AbstractSearchSchemaManagerSimpleOperationIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateOrValidateIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateOrValidateIT.java index d93442845b4..3a0244a1eb7 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateOrValidateIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerCreateOrValidateIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.manager; import org.hibernate.search.mapper.orm.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SearchSchemaManagerCreateOrValidateIT extends AbstractSearchSchemaManagerValidatingSimpleOperationIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerDropAndCreateIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerDropAndCreateIT.java index 41edafe0bca..197814b13e7 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerDropAndCreateIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerDropAndCreateIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.manager; import org.hibernate.search.mapper.orm.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SearchSchemaManagerDropAndCreateIT extends AbstractSearchSchemaManagerSimpleOperationIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerDropIfExistingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerDropIfExistingIT.java index 5182c444058..ec61dfc0fdc 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerDropIfExistingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerDropIfExistingIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.manager; import org.hibernate.search.mapper.orm.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SearchSchemaManagerDropIfExistingIT extends AbstractSearchSchemaManagerSimpleOperationIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerValidateIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerValidateIT.java index 853dd8f1999..3e101b2e20a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerValidateIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/manager/SearchSchemaManagerValidateIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.manager; import org.hibernate.search.mapper.orm.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SearchSchemaManagerValidateIT extends AbstractSearchSchemaManagerValidatingSimpleOperationIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/AbstractSchemaManagementStrategyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/AbstractSchemaManagementStrategyIT.java index 6c633abd985..50e1ab5e809 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/AbstractSchemaManagementStrategyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/AbstractSchemaManagementStrategyIT.java @@ -18,24 +18,24 @@ import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; public abstract class AbstractSchemaManagementStrategyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void noIndexedType() { + void noIndexedType() { SchemaManagementStrategyName strategyName = getStrategyName(); SessionFactory sessionFactory = setupHelper.start() .withProperty( @@ -52,7 +52,7 @@ public void noIndexedType() { } @Test - public void success() { + void success() { expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); expectWork( IndexedEntity2.NAME, CompletableFuture.completedFuture( null ) ); @@ -68,7 +68,7 @@ public void success() { } @Test - public void exception_single() { + void exception_single() { RuntimeException exception = new RuntimeException( "My exception" ); expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); @@ -82,7 +82,7 @@ public void exception_single() { } @Test - public void exception_multiple() { + void exception_multiple() { RuntimeException exception1 = new RuntimeException( "My exception 1" ); RuntimeException exception2 = new RuntimeException( "My exception 2" ); expectWork( IndexedEntity1.NAME, exceptionFuture( exception1 ) ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/AbstractSchemaManagementStrategyValidatingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/AbstractSchemaManagementStrategyValidatingIT.java index 62b55c24240..1d8c3fc5b9f 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/AbstractSchemaManagementStrategyValidatingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/AbstractSchemaManagementStrategyValidatingIT.java @@ -13,12 +13,12 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class AbstractSchemaManagementStrategyValidatingIT extends AbstractSchemaManagementStrategyIT { @Test - public void failure_single() { + void failure_single() { expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); expectWork( IndexedEntity2.NAME, failureCollector -> { failureCollector.add( "My failure" ); @@ -33,7 +33,7 @@ public void failure_single() { } @Test - public void failure_multiple() { + void failure_multiple() { expectWork( IndexedEntity1.NAME, failureCollector -> { failureCollector.add( "My failure 1" ); return CompletableFuture.completedFuture( null ); @@ -53,7 +53,7 @@ public void failure_multiple() { } @Test - public void failure_exception() { + void failure_exception() { RuntimeException exception = new RuntimeException( "My exception" ); expectWork( IndexedEntity1.NAME, failureCollector -> { failureCollector.add( "My failure" ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateIT.java index 05ee4bcf5c2..2d7701ceb4f 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.strategy; import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SchemaManagementStrategyCreateIT extends AbstractSchemaManagementStrategyIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateOrUpdateIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateOrUpdateIT.java index c7678b21bd6..3d1dfea4550 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateOrUpdateIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateOrUpdateIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.strategy; import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SchemaManagementStrategyCreateOrUpdateIT extends AbstractSchemaManagementStrategyIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateOrValidateIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateOrValidateIT.java index c45b2f20825..db39b32259e 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateOrValidateIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyCreateOrValidateIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.strategy; import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SchemaManagementStrategyCreateOrValidateIT extends AbstractSchemaManagementStrategyValidatingIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyDropAndCreateAndDropIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyDropAndCreateAndDropIT.java index 1aeabc4e2b7..ec13d9a5ede 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyDropAndCreateAndDropIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyDropAndCreateAndDropIT.java @@ -10,19 +10,19 @@ import org.hibernate.SessionFactory; import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; import org.hibernate.search.util.impl.test.ExceptionMatcherBuilder; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; -public class SchemaManagementStrategyDropAndCreateAndDropIT extends AbstractSchemaManagementStrategyIT { +class SchemaManagementStrategyDropAndCreateAndDropIT extends AbstractSchemaManagementStrategyIT { - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Override @@ -31,7 +31,7 @@ protected SchemaManagementStrategyName getStrategyName() { } @Test - public void close_drop_exception_single() { + void close_drop_exception_single() { expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); expectWork( IndexedEntity2.NAME, CompletableFuture.completedFuture( null ) ); @@ -53,7 +53,7 @@ public void close_drop_exception_single() { } @Test - public void close_drop_exception_multiple() { + void close_drop_exception_multiple() { expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); expectWork( IndexedEntity2.NAME, CompletableFuture.completedFuture( null ) ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyDropAndCreateIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyDropAndCreateIT.java index 8c20f267376..34f55543b5a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyDropAndCreateIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyDropAndCreateIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.strategy; import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SchemaManagementStrategyDropAndCreateIT extends AbstractSchemaManagementStrategyIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyNoneIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyNoneIT.java index e2a2a668ad3..8e5c6a07b2a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyNoneIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyNoneIT.java @@ -13,22 +13,22 @@ import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SchemaManagementStrategyNoneIT { +class SchemaManagementStrategyNoneIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper setupHelper = OrmSetupHelper.withBackendMock( backendMock ); @Test - public void none() { + void none() { SessionFactory sessionFactory = setup(); // Nothing should have happened backendMock.verifyExpectationsMet(); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyValidateIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyValidateIT.java index 334611b5f03..61ac94c20b8 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyValidateIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/schema/management/strategy/SchemaManagementStrategyValidateIT.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.orm.schema.management.strategy; import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; public class SchemaManagementStrategyValidateIT extends AbstractSchemaManagementStrategyValidatingIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/scope/ScopeExtensionIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/scope/ScopeExtensionIT.java index 4936cb9ba87..fdf13da739c 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/scope/ScopeExtensionIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/scope/ScopeExtensionIT.java @@ -17,33 +17,33 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.impl.StubIndexScope; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ScopeExtensionIT { +class ScopeExtensionIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Author.NAME ); sessionFactory = ormSetupHelper.start().setup( Author.class ); backendMock.verifyExpectationsMet(); } @Test - public void test() { + void test() { with( sessionFactory ).runNoTransaction( session -> { IndexScope indexScope = Search.session( session ).scope( Author.class ) .extension( original -> original ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/SearchQueryBaseIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/SearchQueryBaseIT.java index 8cdd309c7fa..24adee2e079 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/SearchQueryBaseIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/SearchQueryBaseIT.java @@ -39,13 +39,13 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.util.common.SearchTimeoutException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendUtils; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.search.aggregation.impl.StubSearchAggregation; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.search.predicate.impl.StubSearchPredicate; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.search.projection.impl.StubSearchProjection; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.search.sort.impl.StubSearchSort; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.integrationtest.mapper.orm.SlowerLoadingListener; @@ -78,7 +78,7 @@ public class SearchQueryBaseIT { private static final String AUTHOR_AVENUE_OF_MYSTERIES = "John Irving"; @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/AbstractSearchQueryEntityLoadingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/AbstractSearchQueryEntityLoadingIT.java index 7aed9260fc7..5528d789e2e 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/AbstractSearchQueryEntityLoadingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/AbstractSearchQueryEntityLoadingIT.java @@ -26,8 +26,8 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.search.loading.dsl.SearchLoadingOptionsStep; import org.hibernate.search.mapper.orm.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSoftAssertions; public abstract class AbstractSearchQueryEntityLoadingIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/AbstractSearchQueryEntityLoadingSingleTypeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/AbstractSearchQueryEntityLoadingSingleTypeIT.java index f553c9d6326..898530a6558 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/AbstractSearchQueryEntityLoadingSingleTypeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/AbstractSearchQueryEntityLoadingSingleTypeIT.java @@ -31,11 +31,15 @@ protected static void forAllModelMappingCombinations( } } - protected final SingleTypeLoadingModel model; + protected SingleTypeLoadingModel model; - protected final SingleTypeLoadingMapping mapping; + protected SingleTypeLoadingMapping mapping; AbstractSearchQueryEntityLoadingSingleTypeIT(SingleTypeLoadingModel model, SingleTypeLoadingMapping mapping) { + init( model, mapping ); + } + + void init(SingleTypeLoadingModel model, SingleTypeLoadingMapping mapping) { this.model = model; this.mapping = mapping; } diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityChangingScrollingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityChangingScrollingIT.java index 79299ace92f..2a8771d8895 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityChangingScrollingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityChangingScrollingIT.java @@ -30,34 +30,34 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubNextScrollWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubNextScrollWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchQueryEntityChangingScrollingIT { +class SearchQueryEntityChangingScrollingIT { public static final String NEW_NAME = "new-name"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( SimpleEntity.NAME ); sessionFactory = ormSetupHelper.start().setup( SimpleEntity.class ); backendMock.verifyExpectationsMet(); } @Test - public void test() { + void test() { backendMock.inLenientMode( () -> with( sessionFactory ).runInTransaction( session -> { for ( int i = 0; i < 12; i++ ) { session.persist( new SimpleEntity( i ) ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingBaseIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingBaseIT.java index eeba2a8e049..d6970a75ba2 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingBaseIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingBaseIT.java @@ -18,7 +18,8 @@ import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.singletype.SingleTypeLoadingMapping; import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.singletype.SingleTypeLoadingModel; import org.hibernate.search.util.common.SearchTimeoutException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.integrationtest.mapper.orm.TimeoutLoadingListener; @@ -48,7 +49,7 @@ public static List params() { } @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingCacheLookupIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingCacheLookupIT.java index 25c1d49e2fc..4b13e7b2d48 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingCacheLookupIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingCacheLookupIT.java @@ -23,11 +23,12 @@ import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.singletype.SingleTypeLoadingModel; import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.orm.search.loading.EntityLoadingCacheLookupStrategy; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.ExpectedLog4jLogTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; import org.hibernate.stat.Statistics; import org.junit.ClassRule; @@ -59,7 +60,7 @@ public static List params() { } @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); @@ -68,7 +69,7 @@ public static List params() { public MethodRule setupHolderMethodRule = setupHolder.methodRule(); @Rule - public final ExpectedLog4jLog logged = ExpectedLog4jLog.create(); + public final ExpectedLog4jLogTestRule logged = ExpectedLog4jLogTestRule.create(); private final EntityLoadingCacheLookupStrategy defaultCacheLookupStrategy; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingFetchSizeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingFetchSizeIT.java index fab70b95844..c223b2bc07c 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingFetchSizeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingFetchSizeIT.java @@ -16,42 +16,41 @@ import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.singletype.SingleTypeLoadingMapping; import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.singletype.SingleTypeLoadingModel; import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test fetch size of entity loading when executing a search query * when only a single type is involved. */ -@RunWith(Parameterized.class) -public class SearchQueryEntityLoadingFetchSizeIT extends AbstractSearchQueryEntityLoadingSingleTypeIT { +class SearchQueryEntityLoadingFetchSizeIT extends AbstractSearchQueryEntityLoadingSingleTypeIT { - @Parameterized.Parameters(name = "{0}, {1}") - public static List params() { - List result = new ArrayList<>(); + SearchQueryEntityLoadingFetchSizeIT() { + super( null, null ); + } + + public static List params() { + List result = new ArrayList<>(); forAllModelMappingCombinations( (model, mapping) -> { - result.add( new Object[] { model, mapping } ); + result.add( Arguments.of( model, mapping ) ); } ); return result; } - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - public SearchQueryEntityLoadingFetchSizeIT(SingleTypeLoadingModel model, SingleTypeLoadingMapping mapping) { - super( model, mapping ); - } - @Override protected BackendMock backendMock() { return backendMock; @@ -62,9 +61,11 @@ protected SessionFactory sessionFactory() { return sessionFactory; } - @Test + @ParameterizedTest(name = "{0}, {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3349") - public void defaults() { + void defaults(SingleTypeLoadingModel model, SingleTypeLoadingMapping mapping) { + init( model, mapping ); testLoadingFetchSize( // Do not configure search.loading.fetch_size null, @@ -77,9 +78,11 @@ public void defaults() { ); } - @Test + @ParameterizedTest(name = "{0}, {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3349") - public void configurationProperty() { + void configurationProperty(SingleTypeLoadingModel model, SingleTypeLoadingMapping mapping) { + init( model, mapping ); testLoadingFetchSize( // Configure search.loading.fetch_size with this value 50, @@ -92,9 +95,12 @@ public void configurationProperty() { ); } - @Test + + @ParameterizedTest(name = "{0}, {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3349") - public void override_valid() { + void override_valid(SingleTypeLoadingModel model, SingleTypeLoadingMapping mapping) { + init( model, mapping ); testLoadingFetchSize( // Configure search.loading.fetch_size with this value (will be ignored) 100, @@ -107,9 +113,11 @@ public void override_valid() { ); } - @Test + @ParameterizedTest(name = "{0}, {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3349") - public void override_invalid_0() { + void override_invalid_0(SingleTypeLoadingModel model, SingleTypeLoadingMapping mapping) { + init( model, mapping ); assertThatThrownBy( () -> testLoadingFetchSize( // Do not configure search.loading.fetch_size null, @@ -124,9 +132,11 @@ public void override_invalid_0() { .hasMessageContaining( "'fetchSize' must be strictly positive" ); } - @Test + @ParameterizedTest(name = "{0}, {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3349") - public void override_invalid_negative() { + void override_invalid_negative(SingleTypeLoadingModel model, SingleTypeLoadingMapping mapping) { + init( model, mapping ); assertThatThrownBy( () -> testLoadingFetchSize( // Do not configure search.loading.fetch_size null, @@ -146,9 +156,12 @@ public void override_invalid_negative() { * when the collection associations are loaded eagerly. * This used to fail with FetchMode.SUBSELECT. */ - @Test + @ParameterizedTest(name = "{0}, {1}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4150") - public void multipleStatements_lastWithFewerIds_eagerAssociations() { + void multipleStatements_lastWithFewerIds_eagerAssociations(SingleTypeLoadingModel model, + SingleTypeLoadingMapping mapping) { + init( model, mapping ); testLoadingFetchSize( // Set a fetch size lower than the number of entities null, 100, diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingGraphIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingGraphIT.java index e61c2501fc5..6623f1eae00 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingGraphIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingGraphIT.java @@ -20,7 +20,8 @@ import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.singletype.SingleTypeLoadingMapping; import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.singletype.SingleTypeLoadingModel; import org.hibernate.search.mapper.orm.Search; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -50,7 +51,7 @@ public static List params() { } @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingMultipleTypesIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingMultipleTypesIT.java index 4e1d7fe7fb1..943403bdf9a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingMultipleTypesIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingMultipleTypesIT.java @@ -50,7 +50,8 @@ import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.multipletypes.Interface2; import org.hibernate.search.mapper.orm.search.loading.EntityLoadingCacheLookupStrategy; import org.hibernate.search.util.common.SearchTimeoutException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSoftAssertions; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -70,7 +71,7 @@ public class SearchQueryEntityLoadingMultipleTypesIT extends AbstractSearchQueryEntityLoadingIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingNonUniqueDocumentIdIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingNonUniqueDocumentIdIT.java index bb20a4e86f4..cd0e51dd675 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingNonUniqueDocumentIdIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingNonUniqueDocumentIdIT.java @@ -17,34 +17,34 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendUtils; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchQueryEntityLoadingNonUniqueDocumentIdIT { +class SearchQueryEntityLoadingNonUniqueDocumentIdIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( IndexedEntity.NAME ); sessionFactory = ormSetupHelper.start().setup( IndexedEntity.class ); backendMock.verifyExpectationsMet(); } @Test - public void nonUniqueDocumentId() { + void nonUniqueDocumentId() { backendMock.inLenientMode( () -> with( sessionFactory ).runInTransaction( session -> { for ( long i = 0; i < 2; i++ ) { IndexedEntity entity = new IndexedEntity(); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingScrollingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingScrollingIT.java index 75541411309..5d66ead197a 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingScrollingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/search/loading/SearchQueryEntityLoadingScrollingIT.java @@ -15,7 +15,7 @@ import org.hibernate.search.engine.search.query.SearchScrollResult; import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.singletype.SingleTypeLoadingMapping; import org.hibernate.search.integrationtest.mapper.orm.search.loading.model.singletype.SingleTypeLoadingModel; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubNextScrollWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubNextScrollWorkBehavior; public class SearchQueryEntityLoadingScrollingIT extends SearchQueryEntityLoadingBaseIT { diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanBaseIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanBaseIT.java index 617cb186cbd..db8ace50fb3 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanBaseIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanBaseIT.java @@ -26,7 +26,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -43,10 +44,10 @@ public class SearchIndexingPlanBaseIT { private static final String BACKEND2_NAME = "stubBackend2"; @ClassRule - public static BackendMock defaultBackendMock = new BackendMock(); + public static BackendMockTestRule defaultBackendMock = BackendMockTestRule.createGlobal(); @ClassRule - public static BackendMock backend2Mock = new BackendMock(); + public static BackendMockTestRule backend2Mock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanNonEntityIdDocumentIdIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanNonEntityIdDocumentIdIT.java index 0b5aa52a906..88293a52e53 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanNonEntityIdDocumentIdIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanNonEntityIdDocumentIdIT.java @@ -15,7 +15,7 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -31,7 +31,7 @@ public class SearchIndexingPlanNonEntityIdDocumentIdIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanPersistBatchIndexingIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanPersistBatchIndexingIT.java index 66c66c03324..33ffb198786 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanPersistBatchIndexingIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/session/SearchIndexingPlanPersistBatchIndexingIT.java @@ -13,7 +13,8 @@ import org.hibernate.search.mapper.orm.work.SearchIndexingPlan; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @@ -38,7 +39,7 @@ public class SearchIndexingPlanPersistBatchIndexingIT { private static final int ENTITY_COUNT = BATCH_SIZE * 200 + BATCH_SIZE / 2; @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/smoke/AnnotationMappingSmokeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/smoke/AnnotationMappingSmokeIT.java index 8932e16eb92..825e6fc59e9 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/smoke/AnnotationMappingSmokeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/smoke/AnnotationMappingSmokeIT.java @@ -39,8 +39,8 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -52,7 +52,7 @@ public class AnnotationMappingSmokeIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/smoke/ProgrammaticMappingSmokeIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/smoke/ProgrammaticMappingSmokeIT.java index 625bb1c8a4b..bc418dbeef3 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/smoke/ProgrammaticMappingSmokeIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/smoke/ProgrammaticMappingSmokeIT.java @@ -38,8 +38,8 @@ import org.hibernate.search.mapper.pojo.extractor.builtin.BuiltinContainerExtractors; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.ProgrammaticMappingConfigurationContext; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -51,7 +51,7 @@ public class ProgrammaticMappingSmokeIT { @ClassRule - public static BackendMock backendMock = new BackendMock(); + public static BackendMockTestRule backendMock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder = ReusableOrmSetupHolder.withBackendMock( backendMock ); diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/spi/DifferentSessionFactoriesIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/spi/DifferentSessionFactoriesIT.java index fc1b00db66d..c694708eb16 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/spi/DifferentSessionFactoriesIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/spi/DifferentSessionFactoriesIT.java @@ -20,37 +20,37 @@ import org.hibernate.search.mapper.orm.session.impl.HibernateOrmSearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests the creation of a {@link HibernateOrmSearchSession} * using a {@link HibernateSearchContextProviderService} * with an {@link EntityManager} owned by a different {@link SessionFactory}. */ -public class DifferentSessionFactoriesIT { +class DifferentSessionFactoriesIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; private SessionFactory sessionFactoryAlt; - @Before - public void setup() { + @BeforeEach + void setup() { sessionFactory = initABasicSessionFactory(); sessionFactoryAlt = initABasicSessionFactory(); } @Test - public void tryToUseDifferentSessionFactories() { + void tryToUseDifferentSessionFactories() { // mapping is taken from the alternative session factory HibernateSearchContextProviderService contextProvider = sessionFactoryAlt.unwrap( SessionFactoryImplementor.class ) diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/AbstractSearchWorkspaceSimpleOperationIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/AbstractSearchWorkspaceSimpleOperationIT.java index f813289b852..0a10645be41 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/AbstractSearchWorkspaceSimpleOperationIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/AbstractSearchWorkspaceSimpleOperationIT.java @@ -21,7 +21,8 @@ import org.hibernate.search.mapper.orm.Search; import org.hibernate.search.mapper.orm.work.SearchWorkspace; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.orm.BackendMockTestRule; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.ReusableOrmSetupHolder; @@ -35,10 +36,10 @@ public abstract class AbstractSearchWorkspaceSimpleOperationIT { private static final String BACKEND2_NAME = "stubBackend2"; @ClassRule - public static BackendMock defaultBackendMock = new BackendMock(); + public static BackendMockTestRule defaultBackendMock = BackendMockTestRule.createGlobal(); @ClassRule - public static BackendMock backend2Mock = new BackendMock(); + public static BackendMockTestRule backend2Mock = BackendMockTestRule.createGlobal(); @ClassRule public static ReusableOrmSetupHolder setupHolder; diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceFlushIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceFlushIT.java index 4197f85a676..2155d2b4897 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceFlushIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceFlushIT.java @@ -10,7 +10,7 @@ import java.util.concurrent.CompletionStage; import org.hibernate.search.mapper.orm.work.SearchWorkspace; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-3049") diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceMergeSegmentsIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceMergeSegmentsIT.java index f3581a45641..e1d5ab5bbc3 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceMergeSegmentsIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceMergeSegmentsIT.java @@ -10,7 +10,7 @@ import java.util.concurrent.CompletionStage; import org.hibernate.search.mapper.orm.work.SearchWorkspace; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-3049") diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspacePurgeBaseIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspacePurgeBaseIT.java index 7b2719372c4..ad74d1537fe 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspacePurgeBaseIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspacePurgeBaseIT.java @@ -10,7 +10,7 @@ import java.util.concurrent.CompletionStage; import org.hibernate.search.mapper.orm.work.SearchWorkspace; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-3049") diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspacePurgeRoutingKeyIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspacePurgeRoutingKeyIT.java index 50e1f02b47f..9dc0262fe10 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspacePurgeRoutingKeyIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspacePurgeRoutingKeyIT.java @@ -12,7 +12,7 @@ import org.hibernate.search.mapper.orm.work.SearchWorkspace; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-3049") diff --git a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceRefreshIT.java b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceRefreshIT.java index 5bd58012886..9619ec73177 100644 --- a/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceRefreshIT.java +++ b/integrationtest/mapper/orm/src/test/java/org/hibernate/search/integrationtest/mapper/orm/workspace/SearchWorkspaceRefreshIT.java @@ -10,7 +10,7 @@ import java.util.concurrent.CompletionStage; import org.hibernate.search.mapper.orm.work.SearchWorkspace; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-3460") diff --git a/integrationtest/mapper/orm/src/test/java17/org/hibernate/search/integrationtest/mapper/orm/model/IndexedEmbeddedRecordIT.java b/integrationtest/mapper/orm/src/test/java17/org/hibernate/search/integrationtest/mapper/orm/model/IndexedEmbeddedRecordIT.java index e61f778c34f..07ebbd6dd56 100644 --- a/integrationtest/mapper/orm/src/test/java17/org/hibernate/search/integrationtest/mapper/orm/model/IndexedEmbeddedRecordIT.java +++ b/integrationtest/mapper/orm/src/test/java17/org/hibernate/search/integrationtest/mapper/orm/model/IndexedEmbeddedRecordIT.java @@ -23,30 +23,30 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; // This does not work because Hibernate ORM doesn't support instantiating records // for entities/embeddables at the moment. -@Ignore -public class IndexedEmbeddedRecordIT { +@Disabled +class IndexedEmbeddedRecordIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public OrmSetupHelper ormSetupHelper = OrmSetupHelper.withBackendMock( backendMock ); private SessionFactory sessionFactory; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "myRecord", b2 -> b2 .field( "text", String.class, b3 -> b3.analyzerName( AnalyzerNames.DEFAULT ) ) @@ -62,7 +62,7 @@ public void setup() { } @Test - public void index() { + void index() { with( sessionFactory ).runInTransaction( session -> { IndexedEntity entity1 = new IndexedEntity(); entity1.id = 1; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/automaticindexing/DefaultReindexOnUpdateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/automaticindexing/DefaultReindexOnUpdateIT.java index a2ce39ac119..98b1f189d4e 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/automaticindexing/DefaultReindexOnUpdateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/automaticindexing/DefaultReindexOnUpdateIT.java @@ -17,30 +17,30 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test for {@link org.hibernate.search.mapper.pojo.mapping.spi.AbstractPojoMappingInitiator#defaultReindexOnUpdate(ReindexOnUpdate)}. */ -public class DefaultReindexOnUpdateIT { +class DefaultReindexOnUpdateIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { } /** @@ -49,7 +49,7 @@ public void setup() { * then Hibernate Search will handle embedding *and* automatic reindexing. */ @Test - public void default_associationInverseSideKnown() { + void default_associationInverseSideKnown() { backendMock.expectSchema( "ParentEntity", b -> b .field( "value", String.class ) .objectField( "child", b2 -> b2 @@ -135,7 +135,7 @@ public void default_associationInverseSideKnown() { * then Hibernate Search bootstrap will fail. */ @Test - public void default_associationInverseSideUnknown() { + void default_associationInverseSideUnknown() { assertThatThrownBy( () -> setupHelper.start() .withConfiguration( builder -> { @@ -180,7 +180,7 @@ public void default_associationInverseSideUnknown() { * then Hibernate Search will handle embedding, but not automatic reindexing. */ @Test - public void no_associationInverseSideUnknown() { + void no_associationInverseSideUnknown() { backendMock.expectSchema( "ParentEntity", b -> b .field( "value", String.class ) .objectField( "child", b2 -> b2 diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/bootstrap/ConfiguringPropertiesInSearchMappingBuilderIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/bootstrap/ConfiguringPropertiesInSearchMappingBuilderIT.java index b46e729dbbd..f3dca9ba8cb 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/bootstrap/ConfiguringPropertiesInSearchMappingBuilderIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/bootstrap/ConfiguringPropertiesInSearchMappingBuilderIT.java @@ -31,25 +31,25 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurationContext; import org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurer; import org.hibernate.search.util.impl.integrationtest.common.bean.ForbiddenBeanProvider; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; -public class ConfiguringPropertiesInSearchMappingBuilderIT { +class ConfiguringPropertiesInSearchMappingBuilderIT { - @Rule - public BackendMock backend = new BackendMock(); + @RegisterExtension + public BackendMock backend = BackendMock.create(); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Test - public void propertyFileOverridden() { + void propertyFileOverridden() { test( b -> { try ( Reader properties = new InputStreamReader( getClass().getClassLoader().getResourceAsStream( "standalone-test.properties" ), @@ -69,7 +69,7 @@ public void propertyFileOverridden() { } @Test - public void propertyFileOverrides() { + void propertyFileOverrides() { test( b -> { // this should get overridden by the config value from the property file: b.property( diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/bootstrap/FailureReportIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/bootstrap/FailureReportIT.java index dc245ba28c2..388a50dbe1c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/bootstrap/FailureReportIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/bootstrap/FailureReportIT.java @@ -15,17 +15,17 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.ExceptionMatcherBuilder; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; -public class FailureReportIT { +class FailureReportIT { private static final String FAILURE_LOG_INTRODUCTION = "Hibernate Search encountered a failure during bootstrap;" + " continuing for now to list all problems," @@ -37,13 +37,13 @@ public class FailureReportIT { + "\n" + " Standalone POJO mapping: \n"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -52,7 +52,7 @@ public class FailureReportIT { * and check that every failure is reported, and that failures are grouped into a single list. */ @Test - public void multipleFailuresSameContext() { + void multipleFailuresSameContext() { final String indexName = "indexName"; @Indexed(index = indexName) class IndexedEntity { @@ -108,7 +108,7 @@ class IndexedEntity { * and check that every failure is reported. */ @Test - public void multipleFailuresMultipleProperties() { + void multipleFailuresMultipleProperties() { final String indexName = "indexName"; @Indexed(index = indexName) class IndexedEntity { @@ -167,7 +167,7 @@ class IndexedEntity { * and check that every failure is reported. */ @Test - public void multipleFailuresMultipleTypes() { + void multipleFailuresMultipleTypes() { final String indexName1 = "indexName1"; @Indexed(index = indexName1) class IndexedEntity1 { @@ -229,7 +229,7 @@ class IndexedEntity2 { } @Test - public void failuresFromBackend() { + void failuresFromBackend() { final String indexName = "indexName"; @Indexed(index = indexName) class IndexedEntity { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/lifecycle/CleanupIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/lifecycle/CleanupIT.java index 255121e732a..b9bc5820790 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/lifecycle/CleanupIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/lifecycle/CleanupIT.java @@ -6,9 +6,8 @@ */ package org.hibernate.search.integrationtest.mapper.pojo.lifecycle; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; import java.lang.invoke.MethodHandles; import java.util.Arrays; @@ -36,19 +35,19 @@ import org.hibernate.search.mapper.pojo.model.path.PojoModelPath; import org.hibernate.search.mapper.pojo.standalone.mapping.CloseableSearchMapping; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.impl.StubIndexManager; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.impl.StubIndexManagerBuilder; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test that all resources are closed as expected upon shutdown, or when startup fails. */ -public class CleanupIT { +class CleanupIT { private static final StartupStubBridge.CounterKeys IDENTIFIER_BRIDGE_COUNTER_KEYS = StartupStubBridge.createKeys(); private static final StartupStubBridge.CounterKeys ROUTING_BRIDGE_COUNTER_KEYS = StartupStubBridge.createKeys(); private static final StartupStubBridge.CounterKeys TYPE_BRIDGE_COUNTER_KEYS = StartupStubBridge.createKeys(); @@ -57,20 +56,20 @@ public class CleanupIT { StartupStubContainerExtractor.createKeys(); private static final StartupStubBridge.CounterKeys VALUE_BRIDGE_COUNTER_KEYS = StartupStubBridge.createKeys(); - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); private CloseableSearchMapping mapping; @Test - public void successfulBuilding() { + void successfulBuilding() { backendMock.expectAnySchema( IndexedEntity.INDEX ); backendMock.expectAnySchema( OtherIndexedEntity.INDEX ); @@ -93,36 +92,36 @@ public void successfulBuilding() { backendMock.verifyExpectationsMet(); // Exactly 2 index managers are expected - assertEquals( 2, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ); - assertEquals( 0, counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ); - assertEquals( 2, counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ); - assertEquals( 0, counters.get( StubIndexManager.STOP_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ).isEqualTo( 2 ); + assertThat( counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ).isZero(); + assertThat( counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ).isEqualTo( 2 ); + assertThat( counters.get( StubIndexManager.STOP_COUNTER_KEY ) ).isZero(); - assertEquals( 2, counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ); - assertEquals( 2, counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ); + assertThat( counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ).isEqualTo( 2 ); + assertThat( counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ).isEqualTo( 2 ); // Extra type and property bridges should have been created... - assertEquals( 2 + 1, counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ); - assertEquals( 2 + 1, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ).isEqualTo( 2 + 1 ); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ).isEqualTo( 2 + 1 ); // ... but closed immediately because they were only contributing fields that were filtered out - assertEquals( 1, counters.get( TYPE_BRIDGE_COUNTER_KEYS.close ) ); - assertEquals( 1, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.close ) ); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.close ) ).isEqualTo( 1 ); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.close ) ).isEqualTo( 1 ); - assertEquals( 3, counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ); - assertEquals( 4, counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ); + assertThat( counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ).isEqualTo( 3 ); + assertThat( counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ).isEqualTo( 4 ); mapping.close(); mapping = null; // Index manager builders must not have been closed. - assertEquals( 0, counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ).isZero(); // All other instantiated objects must have been closed. assertRuntimeComponentsClosed(); } @Test - public void failingRoutingBinding() { + void failingRoutingBinding() { failingStartup( mappingDefinition -> { TypeMappingStep otherIndexedEntityMapping = mappingDefinition.type( OtherIndexedEntity.class ); otherIndexedEntityMapping.indexed().index( OtherIndexedEntity.INDEX ); @@ -140,24 +139,24 @@ public void failingRoutingBinding() { } ); // We must have instantiated objects... - assertEquals( 2, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ); - assertNotEquals( 0, counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ).isEqualTo( 2 ); + assertThat( counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ).isNotZero(); // ... except index managers... - assertEquals( 0, counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ).isZero(); // ... and all instantiated objects must have been closed. - assertEquals( 0, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) - - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) + - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ).isZero(); assertRuntimeComponentsClosed(); } @Test - public void failingTypeBinding() { + void failingTypeBinding() { failingStartup( mappingDefinition -> { TypeMappingStep otherIndexedEntityMapping = mappingDefinition.type( OtherIndexedEntity.class ); otherIndexedEntityMapping.indexed().index( OtherIndexedEntity.INDEX ) @@ -175,24 +174,24 @@ public void failingTypeBinding() { } ); // We must have instantiated objects... - assertEquals( 2, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ); - assertNotEquals( 0, counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ).isEqualTo( 2 ); + assertThat( counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ).isNotZero(); // ... except index managers... - assertEquals( 0, counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ).isZero(); // ... and all instantiated objects must have been closed. - assertEquals( 0, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) - - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) + - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ).isZero(); assertRuntimeComponentsClosed(); } @Test - public void failingIdentifierBinding() { + void failingIdentifierBinding() { failingStartup( mappingDefinition -> { TypeMappingStep otherIndexedEntityMapping = mappingDefinition.type( OtherIndexedEntity.class ); otherIndexedEntityMapping.indexed().index( OtherIndexedEntity.INDEX ) @@ -210,24 +209,24 @@ public void failingIdentifierBinding() { } ); // We must have instantiated objects... - assertEquals( 2, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ); - assertNotEquals( 0, counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ).isEqualTo( 2 ); + assertThat( counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ).isNotZero(); // ... except index managers... - assertEquals( 0, counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ).isZero(); // ... and all instantiated objects must have been closed. - assertEquals( 0, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) - - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) + - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ).isZero(); assertRuntimeComponentsClosed(); } @Test - public void failingPropertyBinding() { + void failingPropertyBinding() { failingStartup( mappingDefinition -> { TypeMappingStep otherIndexedEntityMapping = mappingDefinition.type( OtherIndexedEntity.class ); otherIndexedEntityMapping.indexed().index( OtherIndexedEntity.INDEX ) @@ -245,24 +244,24 @@ public void failingPropertyBinding() { } ); // We must have instantiated objects... - assertEquals( 2, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ); - assertNotEquals( 0, counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ).isEqualTo( 2 ); + assertThat( counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ).isNotZero(); // ... except index managers... - assertEquals( 0, counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ).isZero(); // ... and all instantiated objects must have been closed. - assertEquals( 0, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) - - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) + - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ).isZero(); assertRuntimeComponentsClosed(); } @Test - public void failingValueBinding() { + void failingValueBinding() { failingStartup( mappingDefinition -> { TypeMappingStep otherIndexedEntityMapping = mappingDefinition.type( OtherIndexedEntity.class ); otherIndexedEntityMapping.indexed().index( OtherIndexedEntity.INDEX ) @@ -283,24 +282,24 @@ public void failingValueBinding() { // We must have instantiated objects... - assertEquals( 2, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ); - assertNotEquals( 0, counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ).isEqualTo( 2 ); + assertThat( counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ).isNotZero(); // ... except index managers... - assertEquals( 0, counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ).isZero(); // ... and all instantiated objects must have been closed. - assertEquals( 0, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) - - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) + - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ).isZero(); assertRuntimeComponentsClosed(); } @Test - public void failingContainerExtractorBuilding() { + void failingContainerExtractorBuilding() { failingStartup( mappingDefinition -> { TypeMappingStep otherIndexedEntityMapping = mappingDefinition.type( OtherIndexedEntity.class ); otherIndexedEntityMapping.indexed().index( OtherIndexedEntity.INDEX ) @@ -325,19 +324,19 @@ public void failingContainerExtractorBuilding() { // We must have instantiated objects... - assertEquals( 2, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ); - assertNotEquals( 0, counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ); - assertNotEquals( 0, counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) ).isEqualTo( 2 ); + assertThat( counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) ).isNotZero(); + assertThat( counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) ).isNotZero(); // ... except index managers... - assertEquals( 0, counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) ).isZero(); // ... and all instantiated objects must have been closed. - assertEquals( 0, counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) - - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ); + assertThat( counters.get( StubIndexManagerBuilder.INSTANCE_COUNTER_KEY ) + - counters.get( StubIndexManagerBuilder.CLOSE_ON_FAILURE_COUNTER_KEY ) ).isZero(); assertRuntimeComponentsClosed(); } @@ -410,30 +409,30 @@ private void startup(Consumer additiona } private void assertRuntimeComponentsClosed() { - assertEquals( 0, counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.close ) ); - assertEquals( 0, counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.holderClose ) ); - assertEquals( 0, counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( ROUTING_BRIDGE_COUNTER_KEYS.close ) ); - assertEquals( 0, counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( ROUTING_BRIDGE_COUNTER_KEYS.holderClose ) ); - assertEquals( 0, counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( TYPE_BRIDGE_COUNTER_KEYS.close ) ); - assertEquals( 0, counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( TYPE_BRIDGE_COUNTER_KEYS.holderClose ) ); - assertEquals( 0, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.close ) ); - assertEquals( 0, counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.holderClose ) ); - assertEquals( 0, counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( VALUE_BRIDGE_COUNTER_KEYS.close ) ); - assertEquals( 0, counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) - - counters.get( VALUE_BRIDGE_COUNTER_KEYS.holderClose ) ); - assertEquals( 0, counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) - - counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.holderClose ) ); - assertEquals( 0, counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) - - counters.get( StubIndexManager.STOP_COUNTER_KEY ) ); + assertThat( counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.close ) ).isZero(); + assertThat( counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( IDENTIFIER_BRIDGE_COUNTER_KEYS.holderClose ) ).isZero(); + assertThat( counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( ROUTING_BRIDGE_COUNTER_KEYS.close ) ).isZero(); + assertThat( counters.get( ROUTING_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( ROUTING_BRIDGE_COUNTER_KEYS.holderClose ) ).isZero(); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( TYPE_BRIDGE_COUNTER_KEYS.close ) ).isZero(); + assertThat( counters.get( TYPE_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( TYPE_BRIDGE_COUNTER_KEYS.holderClose ) ).isZero(); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.close ) ).isZero(); + assertThat( counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( PROPERTY_BRIDGE_COUNTER_KEYS.holderClose ) ).isZero(); + assertThat( counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( VALUE_BRIDGE_COUNTER_KEYS.close ) ).isZero(); + assertThat( counters.get( VALUE_BRIDGE_COUNTER_KEYS.instance ) + - counters.get( VALUE_BRIDGE_COUNTER_KEYS.holderClose ) ).isZero(); + assertThat( counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.instance ) + - counters.get( CONTAINER_VALUE_EXTRACTOR_COUNTER_KEYS.holderClose ) ).isZero(); + assertThat( counters.get( StubIndexManager.INSTANCE_COUNTER_KEY ) + - counters.get( StubIndexManager.STOP_COUNTER_KEY ) ).isZero(); } public static class IndexedEntity { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/loading/LoadingStrategyInheritanceIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/loading/LoadingStrategyInheritanceIT.java index 781db6acfbc..54a163bd079 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/loading/LoadingStrategyInheritanceIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/loading/LoadingStrategyInheritanceIT.java @@ -23,29 +23,29 @@ import org.hibernate.search.mapper.pojo.standalone.loading.MassLoadingStrategy; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4203") // See https://github.com/hibernate/hibernate-search/pull/2564#issuecomment-833808403 -public class LoadingStrategyInheritanceIT { +class LoadingStrategyInheritanceIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private final Map entityMap = new HashMap<>(); - @Before - public void setup() { + @BeforeEach + void setup() { RootEntity root1 = new RootEntity(); root1.id = 1; root1.name = "name1"; @@ -57,7 +57,7 @@ public void setup() { } @Test - public void addEntity_configurer_inheritance() throws InterruptedException { + void addEntity_configurer_inheritance() throws InterruptedException { String rootEntityName = RootEntity.class.getSimpleName(); String derivedEntityName = DerivedEntity.class.getSimpleName(); @@ -111,7 +111,7 @@ public void addEntity_configurer_inheritance() throws InterruptedException { // Same as the test above, but with explicit names @Test - public void addEntity_name_configurer_inheritance() throws InterruptedException { + void addEntity_name_configurer_inheritance() throws InterruptedException { String rootEntityName = "customRootName"; String derivedEntityName = "customDerivedName"; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/IncorrectPropertyNameObjectPathIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/IncorrectPropertyNameObjectPathIT.java index e6e56c2d274..97021f7ad2e 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/IncorrectPropertyNameObjectPathIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/IncorrectPropertyNameObjectPathIT.java @@ -19,25 +19,25 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ObjectPath; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IncorrectPropertyNameObjectPathIT { +class IncorrectPropertyNameObjectPathIT { private static final String BROKEN_PATH_WITH_DOTS = "broken.path.with.dots"; - @Rule - public BackendMock defaultBackendMock = new BackendMock(); + @RegisterExtension + public BackendMock defaultBackendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), defaultBackendMock ); @Test - public void brokenPathWithDotsThrowsException() { + void brokenPathWithDotsThrowsException() { assertThatThrownBy( () -> { setupHelper.start() .withAnnotatedEntityType( Person.class, Person.ENTITY_NAME ) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/SearchMappingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/SearchMappingIT.java index 3a8c4570a93..f865649c22a 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/SearchMappingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/SearchMappingIT.java @@ -30,29 +30,29 @@ import org.hibernate.search.mapper.pojo.standalone.scope.SearchScope; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.reporting.EventContext; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.impl.StubBackend; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.impl.StubIndexManager; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; -public class SearchMappingIT { +class SearchMappingIT { private static final String BACKEND_2_NAME = "stubBackend2"; - @Rule - public BackendMock defaultBackendMock = new BackendMock(); + @RegisterExtension + public BackendMock defaultBackendMock = BackendMock.create(); - @Rule - public BackendMock backend2Mock = new BackendMock(); + @RegisterExtension + public BackendMock backend2Mock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper; private SearchMapping mapping; @@ -64,8 +64,8 @@ public SearchMappingIT() { defaultBackendMock, namedBackendMocks ); } - @Before - public void before() { + @BeforeEach + void before() { defaultBackendMock.expectAnySchema( Person.INDEX_NAME ); backend2Mock.expectAnySchema( Pet.ENTITY_NAME ); mapping = setupHelper.start() @@ -78,7 +78,7 @@ public void before() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void indexedEntity_byName() { + void indexedEntity_byName() { SearchIndexedEntity entity = mapping.indexedEntity( Person.ENTITY_NAME ); assertThat( entity ) .isNotNull() @@ -89,7 +89,7 @@ public void indexedEntity_byName() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void indexedEntity_byName_notEntity() { + void indexedEntity_byName_notEntity() { assertThatThrownBy( () -> mapping.indexedEntity( "invalid" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -105,7 +105,7 @@ public void indexedEntity_byName_notEntity() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void indexedEntity_byName_notIndexed() { + void indexedEntity_byName_notIndexed() { assertThatThrownBy( () -> mapping.indexedEntity( Toy.ENTITY_NAME ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -121,7 +121,7 @@ public void indexedEntity_byName_notIndexed() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void indexedEntity_byJavaClass() { + void indexedEntity_byJavaClass() { SearchIndexedEntity entity = mapping.indexedEntity( Person.class ); assertThat( entity ) .isNotNull() @@ -132,7 +132,7 @@ public void indexedEntity_byJavaClass() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void indexedEntity_byJavaClass_notEntity() { + void indexedEntity_byJavaClass_notEntity() { assertThatThrownBy( () -> mapping.indexedEntity( String.class ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -148,7 +148,7 @@ public void indexedEntity_byJavaClass_notEntity() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void indexedEntity_byJavaClass_notIndexed() { + void indexedEntity_byJavaClass_notIndexed() { assertThatThrownBy( () -> mapping.indexedEntity( Toy.class ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -164,7 +164,7 @@ public void indexedEntity_byJavaClass_notIndexed() { @Test @TestForIssue(jiraKey = "HSEARCH-3589") - public void allIndexedEntities() { + void allIndexedEntities() { Collection> entities = mapping.allIndexedEntities(); assertThat( entities ) .extracting( SearchIndexedEntity::name ) @@ -176,7 +176,7 @@ public void allIndexedEntities() { @Test @TestForIssue(jiraKey = "HSEARCH-3994") - public void scope_indexedEntities() { + void scope_indexedEntities() { SearchScope objectScope = mapping.scope( Object.class ); Set> objectEntities = objectScope.includedTypes(); assertThat( objectEntities ) @@ -205,21 +205,21 @@ public void scope_indexedEntities() { @Test @TestForIssue(jiraKey = "HSEARCH-3640") - public void indexManager_customIndexName() { + void indexManager_customIndexName() { IndexManager indexManager = mapping.indexManager( Person.INDEX_NAME ); checkIndexManager( Person.INDEX_NAME, indexManager ); } @Test @TestForIssue(jiraKey = "HSEARCH-3640") - public void indexManager_defaultIndexName() { + void indexManager_defaultIndexName() { IndexManager indexManager = mapping.indexManager( Pet.ENTITY_NAME ); checkIndexManager( Pet.ENTITY_NAME, indexManager ); } @Test @TestForIssue(jiraKey = "HSEARCH-4656") - public void indexManager_invalidName() { + void indexManager_invalidName() { assertThatThrownBy( () -> mapping.indexManager( "invalid" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -231,21 +231,21 @@ public void indexManager_invalidName() { @Test @TestForIssue(jiraKey = { "HSEARCH-3640", "HSEARCH-3950" }) - public void backend_default() { + void backend_default() { Backend backend = mapping.backend(); checkBackend( EventContexts.defaultBackend(), backend ); } @Test @TestForIssue(jiraKey = "HSEARCH-3640") - public void backend_byName() { + void backend_byName() { Backend backend = mapping.backend( BACKEND_2_NAME ); checkBackend( EventContexts.fromBackendName( BACKEND_2_NAME ), backend ); } @Test @TestForIssue(jiraKey = "HSEARCH-4656") - public void backend_byName_invalidName() { + void backend_byName_invalidName() { assertThatThrownBy( () -> mapping.backend( "invalid" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/SearchMappingNoDefaultBackendIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/SearchMappingNoDefaultBackendIT.java index c6f6271aa91..501c83a72cd 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/SearchMappingNoDefaultBackendIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/SearchMappingNoDefaultBackendIT.java @@ -21,27 +21,26 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchMappingNoDefaultBackendIT { +class SearchMappingNoDefaultBackendIT { private static final String BACKEND_1_NAME = "stubBackend1"; private static final String BACKEND_2_NAME = "stubBackend2"; - @ClassRule - public static BackendMock backend1Mock = new BackendMock(); + @RegisterExtension + public static BackendMock backend1Mock = BackendMock.createGlobal(); - @ClassRule - public static BackendMock backend2Mock = new BackendMock(); + @RegisterExtension + public static BackendMock backend2Mock = BackendMock.createGlobal(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper; private SearchMapping mapping; @@ -54,8 +53,8 @@ public SearchMappingNoDefaultBackendIT() { null, namedBackendMocks ); } - @Before - public void before() { + @BeforeEach + void before() { backend1Mock.expectAnySchema( Person.INDEX_NAME ); backend2Mock.expectAnySchema( Pet.ENTITY_NAME ); mapping = setupHelper.start() @@ -69,7 +68,7 @@ public void before() { @Test @TestForIssue(jiraKey = "HSEARCH-4656") - public void backend_default_nonExisting() { + void backend_default_nonExisting() { assertThatThrownBy( () -> mapping.backend() ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( @@ -81,7 +80,7 @@ public void backend_default_nonExisting() { @Test @TestForIssue(jiraKey = "HSEARCH-4656") - public void backend_byName_invalidName() { + void backend_byName_invalidName() { assertThatThrownBy( () -> mapping.backend( "invalid" ) ) .isInstanceOf( SearchException.class ) .hasMessageContainingAll( diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/alternative/AlternativeBinderIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/alternative/AlternativeBinderIT.java index 2758533d2e3..4b33ef45c4a 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/alternative/AlternativeBinderIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/alternative/AlternativeBinderIT.java @@ -17,32 +17,32 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test a particular use case for type bridges to provide a feature similar to * {@code @AnalyzerDiscriminator} from Hibernate Search 5. */ @TestForIssue(jiraKey = "HSEARCH-3311") -public class AlternativeBinderIT { +class AlternativeBinderIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void smoke() { + void smoke() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -102,7 +102,7 @@ class IndexedEntity { } @Test - public void discriminator_missing() { + void discriminator_missing() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -127,7 +127,7 @@ class IndexedEntity { } @Test - public void discriminator_conflict() { + void discriminator_conflict() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomConstructorMappingAnnotationBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomConstructorMappingAnnotationBaseIT.java index 9fbed60f467..2b0d678077f 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomConstructorMappingAnnotationBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomConstructorMappingAnnotationBaseIT.java @@ -32,34 +32,34 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.reporting.EventContext; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of (custom) constructor mapping annotations. */ @SuppressWarnings("unused") @TestForIssue(jiraKey = "HSEARCH-3927") -public class CustomConstructorMappingAnnotationBaseIT { +class CustomConstructorMappingAnnotationBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); protected final ProjectionFinalStep dummyProjectionForEnclosingClassInstance(SearchProjectionFactory f) { return f.constant( null ); @@ -69,7 +69,7 @@ protected final ProjectionFinalStep dummyProjectionForEnclosingClassInstance( * Basic test checking that a simple constructor mapping will be applied as expected. */ @Test - public void simple() { + void simple() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -142,7 +142,7 @@ public void process(ConstructorMappingStep mapping, } @Test - public void missingProcessorReference() { + void missingProcessorReference() { @Indexed class IndexedEntity { @DocumentId @@ -169,7 +169,7 @@ public IndexedEntity() { } @Test - public void invalidAnnotationType() { + void invalidAnnotationType() { @Indexed class IndexedEntity { @DocumentId @@ -217,7 +217,7 @@ public String toString() { } @Test - public void annotatedElement() { + void annotatedElement() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -337,7 +337,7 @@ else if ( annotatedElement.javaClass().getSimpleName() } @Test - public void eventContext() { + void eventContext() { @Indexed(index = INDEX_NAME) class IndexedEntityType { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomMethodParameterMappingAnnotationBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomMethodParameterMappingAnnotationBaseIT.java index 9778d2204da..4c3a398492d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomMethodParameterMappingAnnotationBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomMethodParameterMappingAnnotationBaseIT.java @@ -33,34 +33,34 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.reporting.EventContext; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of (custom) method parameter mapping annotations. */ @SuppressWarnings("unused") @TestForIssue(jiraKey = "HSEARCH-4574") -public class CustomMethodParameterMappingAnnotationBaseIT { +class CustomMethodParameterMappingAnnotationBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); protected final ProjectionFinalStep dummyProjectionForEnclosingClassInstance(SearchProjectionFactory f) { return f.constant( null ); @@ -70,7 +70,7 @@ protected final ProjectionFinalStep dummyProjectionForEnclosingClassInstance( * Basic test checking that a simple constructor mapping will be applied as expected. */ @Test - public void simple() { + void simple() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -144,7 +144,7 @@ public void process(MethodParameterMappingStep mapping, WorkingAnnotation annota } @Test - public void missingProcessorReference() { + void missingProcessorReference() { @Indexed class IndexedEntity { @DocumentId @@ -171,7 +171,7 @@ public IndexedEntity(@AnnotationWithEmptyProcessorRef Long id) { } @Test - public void invalidAnnotationType() { + void invalidAnnotationType() { @Indexed class IndexedEntity { @DocumentId @@ -220,7 +220,7 @@ public String toString() { } @Test - public void annotatedElement() { + void annotatedElement() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -330,7 +330,7 @@ else if ( annotatedElement.name().get().equals( "paramWithImplicitRepeatableOthe } @Test - public void eventContext() { + void eventContext() { @Indexed(index = INDEX_NAME) class IndexedEntityType { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomPropertyMappingAnnotationBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomPropertyMappingAnnotationBaseIT.java index 9ead817c83f..16338f51d25 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomPropertyMappingAnnotationBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomPropertyMappingAnnotationBaseIT.java @@ -33,27 +33,27 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.reporting.EventContext; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of (custom) property mapping annotations. */ @SuppressWarnings("unused") @TestForIssue(jiraKey = "HSEARCH-3135") -public class CustomPropertyMappingAnnotationBaseIT { +class CustomPropertyMappingAnnotationBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -61,7 +61,7 @@ public class CustomPropertyMappingAnnotationBaseIT { * Basic test checking that a simple property mapping will be applied as expected. */ @Test - public void simple() { + void simple() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -93,7 +93,7 @@ public void process(PropertyMappingStep mapping, WorkingAnnotation annotation, } @Test - public void missingProcessorReference() { + void missingProcessorReference() { @Indexed class IndexedEntity { @DocumentId @@ -117,7 +117,7 @@ class IndexedEntity { } @Test - public void invalidAnnotationType() { + void invalidAnnotationType() { @Indexed class IndexedEntity { @DocumentId @@ -161,7 +161,7 @@ public String toString() { } @Test - public void annotatedElement() { + void annotatedElement() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -298,7 +298,7 @@ else if ( Long.class.equals( annotatedElement.javaClass() ) ) { } @Test - public void eventContext() { + void eventContext() { @Indexed(index = INDEX_NAME) class IndexedEntityType { Integer id; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomTypeMappingAnnotationBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomTypeMappingAnnotationBaseIT.java index b1ed5b1da79..9a33493757d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomTypeMappingAnnotationBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/annotation/processing/CustomTypeMappingAnnotationBaseIT.java @@ -28,27 +28,27 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.reporting.EventContext; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of (custom) type mapping annotations. */ @SuppressWarnings("unused") @TestForIssue(jiraKey = "HSEARCH-3135") -public class CustomTypeMappingAnnotationBaseIT { +class CustomTypeMappingAnnotationBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -56,7 +56,7 @@ public class CustomTypeMappingAnnotationBaseIT { * Basic test checking that a simple type mapping will be applied as expected. */ @Test - public void simple() { + void simple() { @Indexed(index = INDEX_NAME) @WorkingAnnotation class IndexedEntity { @@ -88,7 +88,7 @@ public void process( } @Test - public void missingBinderReference() { + void missingBinderReference() { @Indexed @AnnotationWithEmptyProcessorRef class IndexedEntity { @@ -112,7 +112,7 @@ class IndexedEntity { } @Test - public void invalidAnnotationType() { + void invalidAnnotationType() { @Indexed @AnnotationWithProcessorWithDifferentAnnotationType class IndexedEntity { @@ -154,7 +154,7 @@ public String toString() { } @Test - public void annotatedElement() { + void annotatedElement() { final String index1Name = "index1"; final String index2Name = "index2"; final String index3Name = "index3"; @@ -292,7 +292,7 @@ else if ( annotatedElement.javaClass().getName().endsWith( "IndexedEntityType4" } @Test - public void eventContext() { + void eventContext() { @Indexed(index = INDEX_NAME) @EventContextAwareAnnotation class IndexedEntityType { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AbstractFieldContainerExtractorIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AbstractFieldContainerExtractorIT.java index 1708d23b780..61bad93f660 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AbstractFieldContainerExtractorIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AbstractFieldContainerExtractorIT.java @@ -29,12 +29,12 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test default value bridges for the {@code @GenericField} annotation. @@ -50,10 +50,10 @@ public abstract class AbstractFieldContainerExtractorIT { static final String STRING_VALUE_5 = "5 - Let's stop strings?"; static final String STRING_VALUE_6 = "6 - The last string"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -64,7 +64,7 @@ public abstract class AbstractFieldContainerExtractorIT { } @Test - public void objectArray() { + void objectArray() { doTest( testModelProvider.objectArray(), String.class, true, @@ -75,7 +75,7 @@ public void objectArray() { @Test @TestForIssue(jiraKey = "HSEARCH-3997") - public void booleanArray() { + void booleanArray() { doTest( testModelProvider.booleanArray(), Boolean.class, true, @@ -86,7 +86,7 @@ public void booleanArray() { @Test @TestForIssue(jiraKey = "HSEARCH-3997") - public void charArray() { + void charArray() { doTest( testModelProvider.charArray(), String.class, true, // The Character bridge maps them as Strings @@ -97,7 +97,7 @@ public void charArray() { @Test @TestForIssue(jiraKey = "HSEARCH-3997") - public void byteArray() { + void byteArray() { doTest( testModelProvider.byteArray(), Byte.class, true, @@ -108,7 +108,7 @@ public void byteArray() { @Test @TestForIssue(jiraKey = "HSEARCH-3997") - public void shortArray() { + void shortArray() { doTest( testModelProvider.shortArray(), Short.class, true, @@ -119,7 +119,7 @@ public void shortArray() { @Test @TestForIssue(jiraKey = "HSEARCH-3997") - public void intArray() { + void intArray() { doTest( testModelProvider.intArray(), Integer.class, true, @@ -130,7 +130,7 @@ public void intArray() { @Test @TestForIssue(jiraKey = "HSEARCH-3997") - public void longArray() { + void longArray() { doTest( testModelProvider.longArray(), Long.class, true, @@ -141,7 +141,7 @@ public void longArray() { @Test @TestForIssue(jiraKey = "HSEARCH-3997") - public void floatArray() { + void floatArray() { doTest( testModelProvider.floatArray(), Float.class, true, @@ -152,7 +152,7 @@ public void floatArray() { @Test @TestForIssue(jiraKey = "HSEARCH-3997") - public void doubleArray() { + void doubleArray() { doTest( testModelProvider.doubleArray(), Double.class, true, @@ -162,7 +162,7 @@ public void doubleArray() { } @Test - public void iterable() { + void iterable() { doTest( testModelProvider.iterable(), String.class, true, @@ -172,7 +172,7 @@ public void iterable() { } @Test - public void collection() { + void collection() { doTest( testModelProvider.collection(), String.class, true, @@ -182,7 +182,7 @@ public void collection() { } @Test - public void list() { + void list() { doTest( testModelProvider.list(), String.class, true, @@ -192,7 +192,7 @@ public void list() { } @Test - public void set() { + void set() { doTest( testModelProvider.set(), String.class, true, @@ -203,7 +203,7 @@ public void set() { @Test @TestForIssue(jiraKey = "HSEARCH-2490") - public void sortedSet() { + void sortedSet() { SortedSet set = new TreeSet<>(); // Do not add the strings in order, so as to really rely on the "sort" feature of the set Collections.addAll( set, STRING_VALUE_2, STRING_VALUE_1, STRING_VALUE_3 ); @@ -216,7 +216,7 @@ public void sortedSet() { } @Test - public void mapValues() { + void mapValues() { Map map = new LinkedHashMap<>(); map.put( STRING_VALUE_1, STRING_VALUE_4 ); map.put( STRING_VALUE_2, STRING_VALUE_5 ); @@ -231,7 +231,7 @@ public void mapValues() { @Test @TestForIssue(jiraKey = "HSEARCH-2490") - public void sortedMapValues() { + void sortedMapValues() { SortedMap map = new TreeMap<>(); // Do not add the strings in order, so as to really rely on the "sort" feature of the map map.put( STRING_VALUE_2, STRING_VALUE_5 ); @@ -246,7 +246,7 @@ public void sortedMapValues() { } @Test - public void chain_mapListValues() { + void chain_mapListValues() { Map> map = new LinkedHashMap<>(); map.put( STRING_VALUE_1, CollectionHelper.asList( STRING_VALUE_2, STRING_VALUE_3 ) ); map.put( STRING_VALUE_4, CollectionHelper.asList( STRING_VALUE_5, STRING_VALUE_6 ) ); @@ -259,7 +259,7 @@ public void chain_mapListValues() { } @Test - public void optional_nonEmpty() { + void optional_nonEmpty() { doTest( testModelProvider.optional(), String.class, false, @@ -269,7 +269,7 @@ public void optional_nonEmpty() { } @Test - public void optional_empty() { + void optional_empty() { doTestExpectMissing( testModelProvider.optional(), String.class, false, @@ -278,7 +278,7 @@ public void optional_empty() { } @Test - public void optionalDouble_nonEmpty() { + void optionalDouble_nonEmpty() { doTest( testModelProvider.optionalDouble(), Double.class, false, @@ -288,7 +288,7 @@ public void optionalDouble_nonEmpty() { } @Test - public void optionalDouble_empty() { + void optionalDouble_empty() { doTestExpectMissing( testModelProvider.optionalDouble(), Double.class, false, @@ -297,7 +297,7 @@ public void optionalDouble_empty() { } @Test - public void optionalInt_nonEmpty() { + void optionalInt_nonEmpty() { doTest( testModelProvider.optionalInt(), Integer.class, false, @@ -307,7 +307,7 @@ public void optionalInt_nonEmpty() { } @Test - public void optionalInt_empty() { + void optionalInt_empty() { doTestExpectMissing( testModelProvider.optionalInt(), Integer.class, false, @@ -316,7 +316,7 @@ public void optionalInt_empty() { } @Test - public void optionalLong_nonEmpty() { + void optionalLong_nonEmpty() { doTest( testModelProvider.optionalLong(), Long.class, false, @@ -326,7 +326,7 @@ public void optionalLong_nonEmpty() { } @Test - public void optionalLong_empty() { + void optionalLong_empty() { doTestExpectMissing( testModelProvider.optionalLong(), Long.class, false, @@ -338,7 +338,7 @@ public void optionalLong_empty() { * Test that value bridges are actually applied to each element. */ @Test - public void list_nonPassThroughBridge() { + void list_nonPassThroughBridge() { doTest( testModelProvider.list_implicitEnumBridge(), String.class, true, @@ -352,7 +352,7 @@ public void list_nonPassThroughBridge() { * even when using a container value extractor. */ @Test - public void list_customBridge() { + void list_customBridge() { doTest( () -> setupHelper.start().expectCustomBeans(), testModelProvider.list_explicitPrefixedStringBridge(), diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AbstractProjectionConstructorIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AbstractProjectionConstructorIT.java index 7bdb2208545..efa5f3ddab9 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AbstractProjectionConstructorIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AbstractProjectionConstructorIT.java @@ -15,17 +15,17 @@ import org.hibernate.search.engine.search.projection.dsl.SearchProjectionFactory; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; public abstract class AbstractProjectionConstructorIT { public static final String INDEX_NAME = "index_name"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); protected final ProjectionFinalStep dummyProjectionForEnclosingClassInstance(SearchProjectionFactory f) { return f.constant( null ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AnnotationMappingDiscoveryIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AnnotationMappingDiscoveryIT.java index a5aad66a9eb..8351550b44d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AnnotationMappingDiscoveryIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/AnnotationMappingDiscoveryIT.java @@ -28,23 +28,23 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyBinding; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.ProgrammaticMappingConfigurationContext; import org.hibernate.search.mapper.pojo.model.PojoModelProperty; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class AnnotationMappingDiscoveryIT { +class AnnotationMappingDiscoveryIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void discoveryEnabled() { + void discoveryEnabled() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "annotationMappedEmbedded", b2 -> b2 /* @@ -89,7 +89,7 @@ public void discoveryEnabled() { } @Test - public void discoveryDisabled() { + void discoveryDisabled() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "annotationMappedEmbedded", b2 -> { /* diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DependencyIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DependencyIT.java index 3f63a5d8da3..4c5164dd7bd 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DependencyIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DependencyIT.java @@ -22,26 +22,26 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @SuppressWarnings("unused") -public class DependencyIT { +class DependencyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void associationInverseSide_error_missingInversePath() { + void associationInverseSide_error_missingInversePath() { @Indexed class IndexedEntity { @DocumentId @@ -67,7 +67,7 @@ public IndexedEntity getOther() { } @Test - public void derivedFrom() { + void derivedFrom() { final String indexName = "index1"; @Indexed(index = indexName) class IndexedEntity { @@ -129,7 +129,7 @@ public String getDerived() { @Test @TestForIssue(jiraKey = "HSEARCH-4148") - public void derivedFrom_polymorphism() { + void derivedFrom_polymorphism() { final String index1Name = "index1Name"; final String index2Name = "index2Name"; @Indexed @@ -274,7 +274,7 @@ public String getDerived() { */ @Test @TestForIssue(jiraKey = "HSEARCH-4148") - public void derivedFrom_nonRoot_polymorphism() { + void derivedFrom_nonRoot_polymorphism() { final String indexName = "indexName"; class Model { @Indexed(index = indexName) @@ -443,7 +443,7 @@ public String getDerived() { */ @Test @TestForIssue(jiraKey = "HSEARCH-4148") - public void derivedFrom_nonRoot_polymorphism_prevervesGenerics() { + void derivedFrom_nonRoot_polymorphism_prevervesGenerics() { final String indexName = "indexName"; class Model { @Indexed(index = indexName) @@ -591,7 +591,7 @@ class OtherContainedEntity extends OtherContainedSuperClass { } @Test - public void derivedFrom_error_missingPath() { + void derivedFrom_error_missingPath() { @Indexed class IndexedEntity { @DocumentId @@ -618,7 +618,7 @@ public String getDerived() { } @Test - public void derivedFrom_error_invalidPath() { + void derivedFrom_error_invalidPath() { @Indexed class IndexedEntity { @DocumentId @@ -642,7 +642,7 @@ public String getDerived() { } @Test - public void derivedFrom_error_cycle() { + void derivedFrom_error_cycle() { class DerivedFromCycle { @Indexed class A { @@ -713,7 +713,7 @@ public String getDerivedC() { @Test @TestForIssue(jiraKey = "HSEARCH-4565") - public void derivedFrom_error_cycle_buried() { + void derivedFrom_error_cycle_buried() { class DerivedFromCycle { @Indexed class Zero { @@ -798,7 +798,7 @@ public String getDerivedC() { @Test @TestForIssue(jiraKey = "HSEARCH-4423") - public void derivedFrom_cycleFalsePositive() { + void derivedFrom_cycleFalsePositive() { final String indexName = "myindex"; class DerivedFromCycle { @Indexed(index = indexName) @@ -846,7 +846,7 @@ public String getDerivedA() { } @Test - public void error_cannotInvertAssociation() { + void error_cannotInvertAssociation() { class CannotInvertAssociation { @Indexed class A { @@ -894,7 +894,7 @@ class B { } @Test - public void error_cannotApplyInvertAssociationPath_propertyNotFound() { + void error_cannotApplyInvertAssociationPath_propertyNotFound() { class CannotApplyInvertAssociationPath { @Indexed class A { @@ -935,7 +935,7 @@ class B { } @Test - public void error_cannotApplyInvertAssociationPath_incorrectTargetTypeForInverseAssociation() { + void error_cannotApplyInvertAssociationPath_incorrectTargetTypeForInverseAssociation() { class CannotApplyInvertAssociationPath { @Indexed class A { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DependencyRepeatableIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DependencyRepeatableIT.java index 992bcece377..d72fc65c914 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DependencyRepeatableIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DependencyRepeatableIT.java @@ -23,27 +23,27 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DependencyRepeatableIT { +class DependencyRepeatableIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper .withBackendMock( MethodHandles.lookup(), backendMock ); @Test @TestForIssue(jiraKey = "HSEARCH-4000") - public void associationInverseSide() { + void associationInverseSide() { backendMock.expectSchema( INDEX_NAME, b -> b .objectField( "keys", b2 -> b2 .multiValued( true ) @@ -77,7 +77,7 @@ public void associationInverseSide() { @Test @TestForIssue(jiraKey = "HSEARCH-4000") - public void indexingDependency() { + void indexingDependency() { backendMock.expectSchema( INDEX_NAME, b -> b .objectField( "keys", b2 -> b2 .multiValued( true ) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdBaseIT.java index 3b1c1d633f0..611b0298ea3 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdBaseIT.java @@ -30,15 +30,15 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendUtils; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of the {@code @DocumentId} annotation. @@ -46,19 +46,19 @@ * Does not test default bridges, which are tested in {@link DocumentIdDefaultBridgeBaseIT}. */ @SuppressWarnings("unused") -public class DocumentIdBaseIT { +class DocumentIdBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void identifierBridge_default_noMatch() { + void identifierBridge_default_noMatch() { @Indexed class IndexedEntity { @DocumentId @@ -80,7 +80,7 @@ class IndexedEntity { @Test @SuppressWarnings("rawtypes") - public void identifierBridge_default_noMatch_enumSuperClassRaw() { + void identifierBridge_default_noMatch_enumSuperClassRaw() { @Indexed class IndexedEntity { @DocumentId @@ -101,7 +101,7 @@ class IndexedEntity { } @Test - public void identifierBridge_default_noMatch_enumSuperClassWithWildcard() { + void identifierBridge_default_noMatch_enumSuperClassWithWildcard() { @Indexed class IndexedEntity { @DocumentId @@ -123,7 +123,7 @@ class IndexedEntity { } @Test - public void identifierBridge_default_noMatch_enumSuperClassWithParameters() { + void identifierBridge_default_noMatch_enumSuperClassWithParameters() { @Indexed class IndexedEntity { @DocumentId @@ -150,7 +150,7 @@ enum EnumForEnumSuperClassTest { } @Test - public void identifierBridge_invalidInputType() { + void identifierBridge_invalidInputType() { @Indexed class IndexedEntity { @DocumentId(identifierBridge = @IdentifierBridgeRef(type = MyStringBridge.class)) @@ -190,7 +190,7 @@ public String toString() { @Test @TestForIssue(jiraKey = "HSEARCH-3243") - public void identifierBridge_invalidInputType_superType() { + void identifierBridge_invalidInputType_superType() { @Indexed class IndexedEntity { @DocumentId(identifierBridge = @IdentifierBridgeRef(type = MyNumberBridge.class)) @@ -208,7 +208,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3243") - public void identifierBridge_invalidInputType_subType() { + void identifierBridge_invalidInputType_subType() { @Indexed class IndexedEntity { @DocumentId(identifierBridge = @IdentifierBridgeRef(type = MyNumberBridge.class)) @@ -245,7 +245,7 @@ public String toString() { } @Test - public void identifierBridge_identifierBinder() { + void identifierBridge_identifierBinder() { @Indexed class IndexedEntity { @DocumentId( @@ -271,7 +271,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3243") - public void identifierBridge_implicitInputType_generic() { + void identifierBridge_implicitInputType_generic() { @Indexed class IndexedEntity { @DocumentId(identifierBridge = @IdentifierBridgeRef(type = GenericTypeBridge.class)) @@ -314,7 +314,7 @@ public T fromDocumentIdentifier(String documentIdentifier, } @Test - public void missing() { + void missing() { @Indexed class IndexedEntity { Object id; @@ -335,7 +335,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_annotationMapping() { + void customBridge_withParams_annotationMapping() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId(identifierBinder = @IdentifierBinderRef(type = ParametricBridge.ParametricBinder.class, @@ -380,7 +380,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_paramNotDefined() { + void customBridge_withParams_paramNotDefined() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId(identifierBinder = @IdentifierBinderRef(type = ParametricBridge.ParametricBinder.class)) @@ -406,7 +406,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_paramDefinedTwice() { + void customBridge_withParams_paramDefinedTwice() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId(identifierBinder = @IdentifierBinderRef(type = ParametricBridge.ParametricBinder.class, @@ -438,7 +438,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_programmaticMapping() { + void customBridge_withParams_programmaticMapping() { class IndexedEntity { Integer id; String value; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeAdditionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeAdditionIT.java index c0c37e7acc2..f143c55d56c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeAdditionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeAdditionIT.java @@ -21,30 +21,30 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test adding default identifier bridges so that custom types are supported by the {@code @DocumentId} annotation. */ @TestForIssue(jiraKey = "HSEARCH-3096") -public class DocumentIdDefaultBridgeAdditionIT { +class DocumentIdDefaultBridgeAdditionIT { private static final String INDEX_NAME = "indexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void exactType() { + void exactType() { Consumer configurer = b -> b.exactType( CustomClass.class ) .identifierBridge( new CustomClassBridge() ); @@ -57,7 +57,7 @@ public void exactType() { } @Test - public void subTypesOf() { + void subTypesOf() { Consumer configurer = b -> b.subTypesOf( CustomClass.class ) .identifierBinder( bindingContext -> { Class rawType = bindingContext.bridgedElement().rawType(); @@ -82,7 +82,7 @@ else if ( CustomClassSubclass2.class.equals( rawType ) ) { } @Test - public void strictSubTypesOf() { + void strictSubTypesOf() { Consumer configurer = b -> b.strictSubTypesOf( CustomClass.class ) .identifierBinder( bindingContext -> { Class rawType = bindingContext.bridgedElement().rawType(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeBaseIT.java index 564853abb1f..54e706992ae 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeBaseIT.java @@ -33,52 +33,41 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendUtils; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.model.impl.StubIndexModel; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test default identifier bridges for the {@code @DocumentId} annotation. */ -@RunWith(Parameterized.class) -public class DocumentIdDefaultBridgeBaseIT { +class DocumentIdDefaultBridgeBaseIT { - @Parameterized.Parameters(name = "{0}") - public static Object[] types() { + public static List params() { return PropertyTypeDescriptor.getAll().stream() - .map( type -> new Object[] { type, type.getDefaultIdentifierBridgeExpectations() } ) - .toArray(); + .map( type -> Arguments.of( type, type.getDefaultIdentifierBridgeExpectations() ) ) + .collect( Collectors.toList() ); } - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - private final PropertyTypeDescriptor typeDescriptor; - private final DefaultIdentifierBridgeExpectations expectations; private SearchMapping mapping; private StubIndexModel index1Model; private StubIndexModel index2Model; - public DocumentIdDefaultBridgeBaseIT(PropertyTypeDescriptor typeDescriptor, - DefaultIdentifierBridgeExpectations expectations) { - this.typeDescriptor = typeDescriptor; - this.expectations = expectations; - } - @Before - public void setup() { + void setup(PropertyTypeDescriptor typeDescriptor, DefaultIdentifierBridgeExpectations expectations) { backendMock.expectSchema( DefaultIdentifierBridgeExpectations.TYPE_WITH_IDENTIFIER_BRIDGE_1_NAME, b -> {}, @@ -98,8 +87,10 @@ public void setup() { backendMock.verifyExpectationsMet(); } - @Test - public void indexing() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void indexing(PropertyTypeDescriptor typeDescriptor, DefaultIdentifierBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); Iterator documentIdentifierIterator = typeDescriptor.values().documentIdentifierValues.iterator(); for ( I entityIdentifierValue : typeDescriptor.values().entityModelValues ) { try ( SearchSession session = mapping.createSession() ) { @@ -113,10 +104,13 @@ public void indexing() { backendMock.verifyExpectationsMet(); } - @Test - public void projection_entityReference() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projection_entityReference(PropertyTypeDescriptor typeDescriptor, + DefaultIdentifierBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); try ( SearchSession session = mapping.createSession() ) { - Iterator entityIdentifierIterator = getProjectionValues().iterator(); + Iterator entityIdentifierIterator = getProjectionValues( typeDescriptor ).iterator(); for ( String documentIdentifierValue : typeDescriptor.values().documentIdentifierValues ) { I entityIdentifierValue = entityIdentifierIterator.next(); backendMock.expectSearchReferences( @@ -147,10 +141,12 @@ public void projection_entityReference() { } } - @Test - public void projection_id() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projection_id(PropertyTypeDescriptor typeDescriptor, DefaultIdentifierBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); try ( SearchSession session = mapping.createSession() ) { - Iterator entityIdentifierIterator = getProjectionValues().iterator(); + Iterator entityIdentifierIterator = getProjectionValues( typeDescriptor ).iterator(); for ( String documentIdentifierValue : typeDescriptor.values().documentIdentifierValues ) { I entityIdentifierValue = entityIdentifierIterator.next(); backendMock.expectSearchIds( @@ -176,8 +172,10 @@ public void projection_id() { } // Test behavior that backends expect from our bridges when using the DSLs - @Test - public void dslConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dslConverter(PropertyTypeDescriptor typeDescriptor, DefaultIdentifierBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); // This cast may be unsafe, but only if something is deeply wrong, and then an exception will be thrown below @SuppressWarnings("unchecked") DslConverter dslConverter = @@ -217,8 +215,10 @@ public void dslConverter() { } // Test behavior that backends expect from our bridges when using the identifier projections - @Test - public void projectionConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConverter(PropertyTypeDescriptor typeDescriptor, DefaultIdentifierBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); // This cast may be unsafe, but only if something is deeply wrong, and then an exception will be thrown below @SuppressWarnings("unchecked") ProjectionConverter projectionConverter = @@ -267,7 +267,7 @@ public void projectionConverter() { } } - private List getProjectionValues() { + private List getProjectionValues(PropertyTypeDescriptor typeDescriptor) { return typeDescriptor.values().entityModelValues.stream() .map( typeDescriptor::toProjectedValue ) .collect( Collectors.toList() ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeOverridingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeOverridingIT.java index 4304656e4d0..7a031f44d4b 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeOverridingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/DocumentIdDefaultBridgeOverridingIT.java @@ -10,6 +10,8 @@ import java.lang.invoke.MethodHandles; import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; import org.hibernate.search.engine.backend.types.converter.runtime.ToDocumentValueConvertContext; import org.hibernate.search.engine.backend.types.converter.runtime.spi.ToDocumentValueConvertContextImpl; @@ -24,54 +26,42 @@ import org.hibernate.search.mapper.pojo.common.spi.PojoEntityReference; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendUtils; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.model.impl.StubIndexModel; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test overriding default identifier bridges for the {@code @DocumentId} annotation, * for example assigning a different default identifier bridge for properties of type {@link String}. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3096") -public class DocumentIdDefaultBridgeOverridingIT { +class DocumentIdDefaultBridgeOverridingIT { - @Parameterized.Parameters(name = "{0}") - public static Object[] types() { + public static List params() { return PropertyTypeDescriptor.getAll().stream() - .map( type -> new Object[] { type, type.getDefaultIdentifierBridgeExpectations() } ) - .toArray(); + .map( type -> Arguments.of( type, type.getDefaultIdentifierBridgeExpectations() ) ) + .collect( Collectors.toList() ); } - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - private final PropertyTypeDescriptor typeDescriptor; - private final DefaultIdentifierBridgeExpectations expectations; private SearchMapping mapping; private StubIndexModel indexModel; - public DocumentIdDefaultBridgeOverridingIT(PropertyTypeDescriptor typeDescriptor, - DefaultIdentifierBridgeExpectations expectations) { - this.typeDescriptor = typeDescriptor; - this.expectations = expectations; - } - - @Before - public void setup() { + public void setup(PropertyTypeDescriptor typeDescriptor, DefaultIdentifierBridgeExpectations expectations) { backendMock.expectSchema( DefaultIdentifierBridgeExpectations.TYPE_WITH_IDENTIFIER_BRIDGE_1_NAME, b -> {}, @@ -82,15 +72,18 @@ public void setup() { DefaultIdentifierBridgeExpectations.TYPE_WITH_IDENTIFIER_BRIDGE_1_NAME ) // HERE we override the default bridge for the type being tested. .withConfiguration( builder -> builder.bridges().exactType( typeDescriptor.getJavaType() ) - .identifierBridge( new OverridingDefaultBridge() ) ) + .identifierBridge( new OverridingDefaultBridge( typeDescriptor ) ) ) .setup(); backendMock.verifyExpectationsMet(); } - @Test - public void indexing() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void indexing(PropertyTypeDescriptor typeDescriptor, DefaultIdentifierBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); try ( SearchSession session = mapping.createSession() ) { - Object entity = expectations.instantiateTypeWithIdentifierBridge1( getEntityIdentifierValue() ); + Object entity = expectations.instantiateTypeWithIdentifierBridge1( getEntityIdentifierValue( + typeDescriptor ) ); session.indexingPlan().add( entity ); backendMock.expectWorks( DefaultIdentifierBridgeExpectations.TYPE_WITH_IDENTIFIER_BRIDGE_1_NAME ) @@ -99,8 +92,11 @@ public void indexing() { backendMock.verifyExpectationsMet(); } - @Test - public void projection_entityReference() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projection_entityReference(PropertyTypeDescriptor typeDescriptor, + DefaultIdentifierBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); try ( SearchSession session = mapping.createSession() ) { backendMock.expectSearchReferences( Collections.singletonList( DefaultIdentifierBridgeExpectations.TYPE_WITH_IDENTIFIER_BRIDGE_1_NAME ), @@ -122,14 +118,16 @@ public void projection_entityReference() { .containsExactly( PojoEntityReference.withName( expectations.getTypeWithIdentifierBridge1(), DefaultIdentifierBridgeExpectations.TYPE_WITH_IDENTIFIER_BRIDGE_1_NAME, - getEntityIdentifierValue() + getEntityIdentifierValue( typeDescriptor ) ) ); backendMock.verifyExpectationsMet(); } } - @Test - public void projection_id() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projection_id(PropertyTypeDescriptor typeDescriptor, DefaultIdentifierBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); try ( SearchSession session = mapping.createSession() ) { backendMock.expectSearchIds( Collections.singletonList( DefaultIdentifierBridgeExpectations.TYPE_WITH_IDENTIFIER_BRIDGE_1_NAME ), @@ -146,14 +144,16 @@ public void projection_id() { .toQuery(); assertThat( query.fetchAll().hits() ) - .containsExactly( getEntityIdentifierValue() ); + .containsExactly( getEntityIdentifierValue( typeDescriptor ) ); backendMock.verifyExpectationsMet(); } } // Test behavior that backends expect from our bridges when using the DSLs - @Test - public void dslToIndexConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dslToIndexConverter(PropertyTypeDescriptor typeDescriptor, DefaultIdentifierBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); // This cast may be unsafe, but only if something is deeply wrong, and then an exception will be thrown below @SuppressWarnings("unchecked") DslConverter dslConverter = @@ -162,13 +162,13 @@ public void dslToIndexConverter() { new ToDocumentValueConvertContextImpl( BridgeTestUtils.toBackendMappingContext( mapping ) ); // The overriden default bridge must be used by the DSL converter - assertThat( dslConverter.toDocumentValue( getEntityIdentifierValue(), convertContext ) ) + assertThat( dslConverter.toDocumentValue( getEntityIdentifierValue( typeDescriptor ), convertContext ) ) .isEqualTo( getDocumentIdentifierValue() ); - assertThat( dslConverter.unknownTypeToDocumentValue( getEntityIdentifierValue(), convertContext ) ) + assertThat( dslConverter.unknownTypeToDocumentValue( getEntityIdentifierValue( typeDescriptor ), convertContext ) ) .isEqualTo( getDocumentIdentifierValue() ); } - private I getEntityIdentifierValue() { + private I getEntityIdentifierValue(PropertyTypeDescriptor typeDescriptor) { return typeDescriptor.values().entityModelValues.get( 0 ); } @@ -179,12 +179,17 @@ private String getDocumentIdentifierValue() { private class OverridingDefaultBridge implements IdentifierBridge { private static final String DOCUMENT_ID = "OVERRIDDEN_ID"; + private final PropertyTypeDescriptor typeDescriptor; + + private OverridingDefaultBridge(PropertyTypeDescriptor typeDescriptor) { + this.typeDescriptor = typeDescriptor; + } @Override public I fromDocumentIdentifier(String documentIdentifier, IdentifierBridgeFromDocumentIdentifierContext context) { // We only support one ID value: this is just a stub - return getEntityIdentifierValue(); + return getEntityIdentifierValue( typeDescriptor ); } @Override diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldBaseIT.java index 773382a5bf1..c76ad982536 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldBaseIT.java @@ -21,13 +21,13 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of the {@code @*Field} annotations. @@ -40,19 +40,19 @@ * Does not test uses of container value extractors, which are tested in {@link FieldContainerExtractorBaseIT} * (and others, see javadoc on that class). */ -public class FieldBaseIT { +class FieldBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void valueBridge_default_noMatch() { + void valueBridge_default_noMatch() { @Indexed class IndexedEntity { @DocumentId @@ -74,7 +74,7 @@ class IndexedEntity { @Test @SuppressWarnings("rawtypes") - public void valueBridge_default_noMatch_enumSuperClassRaw() { + void valueBridge_default_noMatch_enumSuperClassRaw() { @Indexed class IndexedEntity { @DocumentId @@ -94,7 +94,7 @@ class IndexedEntity { } @Test - public void valueBridge_default_noMatch_enumSuperClassWithWildcard() { + void valueBridge_default_noMatch_enumSuperClassWithWildcard() { @Indexed class IndexedEntity { @DocumentId @@ -115,7 +115,7 @@ class IndexedEntity { } @Test - public void valueBridge_default_noMatch_enumSuperClassWithParameters() { + void valueBridge_default_noMatch_enumSuperClassWithParameters() { @Indexed class IndexedEntity { @DocumentId @@ -141,7 +141,7 @@ enum EnumForEnumSuperClassTest { } @Test - public void valueBridge_invalidInputType() { + void valueBridge_invalidInputType() { @Indexed class IndexedEntity { @DocumentId @@ -161,7 +161,7 @@ class IndexedEntity { } @Test - public void valueBridge_invalidInputType_implicitContainerExtractor() { + void valueBridge_invalidInputType_implicitContainerExtractor() { @Indexed class IndexedEntity { @DocumentId @@ -197,7 +197,7 @@ public String toString() { } @Test - public void valueBridge_valueBinder() { + void valueBridge_valueBinder() { @Indexed class IndexedEntity { @DocumentId @@ -224,7 +224,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3243") - public void valueBridge_implicitInputType_generic() { + void valueBridge_implicitInputType_generic() { @Indexed class IndexedEntity { @DocumentId @@ -262,7 +262,7 @@ public String toIndexedValue(T value, ValueBridgeToIndexedValueContext context) } @Test - public void indexNullAs() { + void indexNullAs() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -302,7 +302,7 @@ public Integer parse(String value) { } @Test - public void indexNullAs_noParsing() { + void indexNullAs_noParsing() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldContainerExtractorBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldContainerExtractorBaseIT.java index a7c1f4d8ef7..5dff90e300c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldContainerExtractorBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldContainerExtractorBaseIT.java @@ -25,13 +25,13 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test error cases when applying container value extractors in the {@code @GenericField} annotation. @@ -40,19 +40,19 @@ * and {@link FieldContainerExtractorExplicitIT}. */ @TestForIssue(jiraKey = "HSEARCH-2554") -public class FieldContainerExtractorBaseIT { +class FieldContainerExtractorBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void custom() { + void custom() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -114,7 +114,7 @@ public void extract(MyContainer container, ValueProcessor, String> myProperty) { } @Test - public void containerBridge() { + void containerBridge() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldContainerExtractorImplicitIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldContainerExtractorImplicitIT.java index f8424b5989f..bfa586abc21 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldContainerExtractorImplicitIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldContainerExtractorImplicitIT.java @@ -29,7 +29,7 @@ * Error cases are not tested here but in {@link FieldContainerExtractorBaseIT}. */ @TestForIssue(jiraKey = "HSEARCH-2554") -public class FieldContainerExtractorImplicitIT extends AbstractFieldContainerExtractorIT { +class FieldContainerExtractorImplicitIT extends AbstractFieldContainerExtractorIT { public FieldContainerExtractorImplicitIT() { super( new ImplicitContainerExtractorTestModelProvider() ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeAdditionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeAdditionIT.java index 8a4ddf5149c..5f8b07ea3a0 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeAdditionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeAdditionIT.java @@ -22,30 +22,30 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test adding default value bridges so that custom types are supported by the {@code @GenericField} annotation. */ @TestForIssue(jiraKey = "HSEARCH-3096") -public class FieldDefaultBridgeAdditionIT { +class FieldDefaultBridgeAdditionIT { private static final String INDEX_NAME = "indexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void exactType() { + void exactType() { Consumer configurer = b -> b.exactType( CustomClass.class ) .valueBridge( new CustomClassBridge() ); @@ -59,7 +59,7 @@ public void exactType() { } @Test - public void subTypesOf() { + void subTypesOf() { Consumer configurer = b -> b.subTypesOf( CustomClass.class ) .valueBinder( bindingContext -> { Class rawType = bindingContext.bridgedElement().rawType(); @@ -86,7 +86,7 @@ else if ( CustomClassSubclass2.class.equals( rawType ) ) { } @Test - public void strictSubTypesOf() { + void strictSubTypesOf() { Consumer configurer = b -> b.strictSubTypesOf( CustomClass.class ) .valueBinder( bindingContext -> { Class rawType = bindingContext.bridgedElement().rawType(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeBaseIT.java index e475e2ec603..8b53e8c05d3 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeBaseIT.java @@ -31,54 +31,42 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.model.impl.StubIndexNode; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test default value bridges for the {@code @GenericField} annotation. */ -@RunWith(Parameterized.class) -public class FieldDefaultBridgeBaseIT { +class FieldDefaultBridgeBaseIT { private static final String FIELD_NAME = DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_FIELD_NAME; private static final String FIELD_INDEXNULLAS_NAME = DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_FIELD_INDEXNULLAS_NAME; - @Parameterized.Parameters(name = "{0}") - public static Object[] types() { + public static List params() { return PropertyTypeDescriptor.getAll().stream() - .map( type -> new Object[] { type, type.getDefaultValueBridgeExpectations() } ) - .toArray(); + .map( type -> Arguments.of( type, type.getDefaultValueBridgeExpectations() ) ) + .collect( Collectors.toList() ); } - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - private final PropertyTypeDescriptor typeDescriptor; - private final DefaultValueBridgeExpectations expectations; private SearchMapping mapping; private StubIndexNode index1Field; private StubIndexNode index2Field; - public FieldDefaultBridgeBaseIT(PropertyTypeDescriptor typeDescriptor, - DefaultValueBridgeExpectations expectations) { - this.typeDescriptor = typeDescriptor; - this.expectations = expectations; - } - - @Before - public void setup() { + public void setup(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { backendMock.expectSchema( DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_1_NAME, b -> { b.field( FIELD_NAME, expectations.getIndexFieldJavaType() ); @@ -110,11 +98,13 @@ public void setup() { backendMock.verifyExpectationsMet(); } - @Test - public void indexing() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void indexing(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); try ( SearchSession session = mapping.createSession() ) { int id = 0; - for ( V propertyValue : getPropertyValues() ) { + for ( V propertyValue : getPropertyValues( typeDescriptor ) ) { Object entity = expectations.instantiateTypeWithValueBridge1( id, propertyValue ); session.indexingPlan().add( entity ); ++id; @@ -124,7 +114,7 @@ public void indexing() { DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_1_NAME ); id = 0; - for ( F expectedFieldValue : getDocumentFieldValues() ) { + for ( F expectedFieldValue : getDocumentFieldValues( typeDescriptor ) ) { expectationSetter.add( String.valueOf( id ), b -> { b.field( FIELD_NAME, expectedFieldValue ); @@ -139,8 +129,10 @@ public void indexing() { backendMock.verifyExpectationsMet(); } - @Test - public void projection() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projection(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); try ( SearchSession session = mapping.createSession() ) { SearchQuery query = session.search( expectations.getTypeWithValueBridge1() ) .select( f -> f.field( FIELD_NAME, typeDescriptor.getBoxedJavaType() ) ) @@ -151,18 +143,20 @@ public void projection() { DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_1_NAME, StubSearchWorkBehavior.of( 2L, - getDocumentFieldValues().toArray() + getDocumentFieldValues( typeDescriptor ).toArray() ) ); assertThat( query.fetchAll().hits() ) - .containsExactlyElementsOf( getProjectionValues() ); + .containsExactlyElementsOf( getProjectionValues( typeDescriptor ) ); } } // Test behavior that backends expect from our bridges when using the DSLs - @Test - public void dslConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dslConverter(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); // This cast may be unsafe, but only if something is deeply wrong, and then an exception will be thrown below @SuppressWarnings("unchecked") DslConverter dslConverter = @@ -188,8 +182,8 @@ public void dslConverter() { dslConverter.unknownTypeToDocumentValue( null, toDocumentConvertContext ) ) .isNull(); - Iterator fieldValuesIterator = getDocumentFieldValues().iterator(); - for ( V propertyValue : getPropertyValues() ) { + Iterator fieldValuesIterator = getDocumentFieldValues( typeDescriptor ).iterator(); + for ( V propertyValue : getPropertyValues( typeDescriptor ) ) { F fieldValue = fieldValuesIterator.next(); assertThat( dslConverter.toDocumentValue( propertyValue, toDocumentConvertContext ) @@ -210,8 +204,10 @@ public void dslConverter() { } // Test behavior that backends expect from our bridges when using projections - @Test - public void projectionConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projectionConverter(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); // This cast may be unsafe, but only if something is deeply wrong, and then an exception will be thrown below @SuppressWarnings("unchecked") ProjectionConverter projectionConverter = @@ -253,8 +249,8 @@ public void projectionConverter() { projectionConverter.fromDocumentValue( null, fromDocumentConvertContext ) ) .isNull(); - Iterator projectionValuesIterator = getProjectionValues().iterator(); - for ( F fieldValue : getDocumentFieldValues() ) { + Iterator projectionValuesIterator = getProjectionValues( typeDescriptor ).iterator(); + for ( F fieldValue : getDocumentFieldValues( typeDescriptor ) ) { V projectionValue = projectionValuesIterator.next(); assertThat( projectionConverter.fromDocumentValue( fieldValue, fromDocumentConvertContext ) @@ -264,7 +260,7 @@ public void projectionConverter() { } } - private List getPropertyValues() { + private List getPropertyValues(PropertyTypeDescriptor typeDescriptor) { List propertyValues = new ArrayList<>( typeDescriptor.values().entityModelValues ); if ( typeDescriptor.isNullable() ) { propertyValues.add( null ); @@ -272,7 +268,7 @@ private List getPropertyValues() { return propertyValues; } - private List getProjectionValues() { + private List getProjectionValues(PropertyTypeDescriptor typeDescriptor) { List values = typeDescriptor.values().entityModelValues.stream() .map( typeDescriptor::toProjectedValue ) .collect( Collectors.toList() ); @@ -282,7 +278,7 @@ private List getProjectionValues() { return values; } - private List getDocumentFieldValues() { + private List getDocumentFieldValues(PropertyTypeDescriptor typeDescriptor) { List documentFieldValues = new ArrayList<>( typeDescriptor.values().documentFieldValues ); if ( typeDescriptor.isNullable() ) { documentFieldValues.add( null ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeOverridingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeOverridingIT.java index 745a02c34a4..76a012b1309 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeOverridingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FieldDefaultBridgeOverridingIT.java @@ -9,7 +9,9 @@ import static org.assertj.core.api.Assertions.assertThat; import java.lang.invoke.MethodHandles; +import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; import org.hibernate.search.engine.backend.types.converter.runtime.ToDocumentValueConvertContext; import org.hibernate.search.engine.backend.types.converter.runtime.spi.ToDocumentValueConvertContextImpl; @@ -22,56 +24,44 @@ import org.hibernate.search.mapper.pojo.bridge.runtime.ValueBridgeToIndexedValueContext; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.model.impl.StubIndexNode; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Test overriding default value bridges for the {@code @GenericField} annotation, * for example assigning a different default value bridge for properties of type {@link String}. */ -@RunWith(Parameterized.class) @TestForIssue(jiraKey = "HSEARCH-3096") -public class FieldDefaultBridgeOverridingIT { +class FieldDefaultBridgeOverridingIT { private static final String FIELD_NAME = DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_FIELD_NAME; private static final String FIELD_INDEXNULLAS_NAME = DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_FIELD_INDEXNULLAS_NAME; - @Parameterized.Parameters(name = "{0}") - public static Object[] types() { + public static List params() { return PropertyTypeDescriptor.getAll().stream() - .map( type -> new Object[] { type, type.getDefaultValueBridgeExpectations() } ) - .toArray(); + .map( type -> Arguments.of( type, type.getDefaultValueBridgeExpectations() ) ) + .collect( Collectors.toList() ); } - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - private final PropertyTypeDescriptor typeDescriptor; - private final DefaultValueBridgeExpectations expectations; private SearchMapping mapping; private StubIndexNode indexField; - public FieldDefaultBridgeOverridingIT(PropertyTypeDescriptor typeDescriptor, - DefaultValueBridgeExpectations expectations) { - this.typeDescriptor = typeDescriptor; - this.expectations = expectations; - } - - @Before - public void setup() { + public void setup(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { backendMock.expectSchema( DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_1_NAME, b -> { b.field( FIELD_NAME, FieldTypeForOverridingDefaultBridge.class ); @@ -93,15 +83,17 @@ public void setup() { backendMock.verifyExpectationsMet(); } - @Test - public void indexing() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void indexing(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); try ( SearchSession session = mapping.createSession() ) { - Object entity = expectations.instantiateTypeWithValueBridge1( 1, getPropertyValue() ); + Object entity = expectations.instantiateTypeWithValueBridge1( 1, getPropertyValue( typeDescriptor ) ); session.indexingPlan().add( entity ); backendMock.expectWorks( DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_1_NAME ) .add( "1", b -> { - b.field( FIELD_NAME, getFieldValue() ); + b.field( FIELD_NAME, getFieldValue( typeDescriptor ) ); if ( typeDescriptor.isNullable() ) { // The stub backend does not implement the 'indexNullAs' option @@ -112,8 +104,10 @@ public void indexing() { backendMock.verifyExpectationsMet(); } - @Test - public void projection() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void projection(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); try ( SearchSession session = mapping.createSession() ) { SearchQuery query = session.search( expectations.getTypeWithValueBridge1() ) .select( f -> f.field( FIELD_NAME, typeDescriptor.getBoxedJavaType() ) ) @@ -124,16 +118,18 @@ public void projection() { DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_1_NAME, StubSearchWorkBehavior.of( 1L, - getFieldValue() + getFieldValue( typeDescriptor ) ) ); - assertThat( query.fetchAll().hits() ).containsExactly( getPropertyValue() ); + assertThat( query.fetchAll().hits() ).containsExactly( getPropertyValue( typeDescriptor ) ); } } - @Test - public void dslConverter() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void dslConverter(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { + setup( typeDescriptor, expectations ); // This cast may be unsafe, but only if something is deeply wrong, and then an exception will be thrown below @SuppressWarnings("unchecked") DslConverter dslConverter = @@ -142,18 +138,18 @@ public void dslConverter() { new ToDocumentValueConvertContextImpl( BridgeTestUtils.toBackendMappingContext( mapping ) ); // The overriden default bridge must be used by the DSL converter - assertThat( dslConverter.toDocumentValue( getPropertyValue(), toDocumentConvertContext ) ) - .isEqualTo( getFieldValue() ); - assertThat( dslConverter.unknownTypeToDocumentValue( getPropertyValue(), toDocumentConvertContext ) ) - .isEqualTo( getFieldValue() ); + assertThat( dslConverter.toDocumentValue( getPropertyValue( typeDescriptor ), toDocumentConvertContext ) ) + .isEqualTo( getFieldValue( typeDescriptor ) ); + assertThat( dslConverter.unknownTypeToDocumentValue( getPropertyValue( typeDescriptor ), toDocumentConvertContext ) ) + .isEqualTo( getFieldValue( typeDescriptor ) ); } - private V getPropertyValue() { + private V getPropertyValue(PropertyTypeDescriptor typeDescriptor) { return typeDescriptor.values().entityModelValues.get( 0 ); } - private FieldTypeForOverridingDefaultBridge getFieldValue() { - return new FieldTypeForOverridingDefaultBridge( getPropertyValue() ); + private FieldTypeForOverridingDefaultBridge getFieldValue(PropertyTypeDescriptor typeDescriptor) { + return new FieldTypeForOverridingDefaultBridge( getPropertyValue( typeDescriptor ) ); } private static class FieldTypeForOverridingDefaultBridge { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FullTextFieldIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FullTextFieldIT.java index 1d791a4b9b4..aad8613c339 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FullTextFieldIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/FullTextFieldIT.java @@ -32,13 +32,13 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of the {@link FullTextField} annotation. @@ -50,19 +50,19 @@ * Does not test uses of container value extractors, which are tested in {@link FieldContainerExtractorBaseIT} * (and others, see javadoc on that class). */ -public class FullTextFieldIT { +class FullTextFieldIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void defaultAttributes() { + void defaultAttributes() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -80,7 +80,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-4123") - public void defaultAttributes_programmaticAPI() { + void defaultAttributes_programmaticAPI() { class IndexedEntity { Integer id; String value; @@ -101,7 +101,7 @@ class IndexedEntity { } @Test - public void name() { + void name() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -118,7 +118,7 @@ class IndexedEntity { } @Test - public void name_invalid_dot() { + void name_invalid_dot() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -139,7 +139,7 @@ class IndexedEntity { } @Test - public void defaultBridge() { + void defaultBridge() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -162,7 +162,7 @@ class IndexedEntity { } @Test - public void norms() { + void norms() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -188,7 +188,7 @@ class IndexedEntity { } @Test - public void searchable() { + void searchable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -214,7 +214,7 @@ class IndexedEntity { } @Test - public void termVector() { + void termVector() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -244,7 +244,7 @@ class IndexedEntity { } @Test - public void analyzer() { + void analyzer() { final String analyzerName = "analyzerName"; @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -262,7 +262,7 @@ class IndexedEntity { } @Test - public void searchAnalyzer() { + void searchAnalyzer() { final String searchAnalyzerName = "searchAnalyzerName"; @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -281,7 +281,7 @@ class IndexedEntity { } @Test - public void analyzer_searchAnalyzer() { + void analyzer_searchAnalyzer() { final String analyzerName = "analyzerName"; final String searchAnalyzerName = "searchAnalyzerName"; @Indexed(index = INDEX_NAME) @@ -301,7 +301,7 @@ class IndexedEntity { } @Test - public void customBridge_implicitFieldType() { + void customBridge_implicitFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -318,7 +318,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType() { + void customBridge_explicitFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -335,7 +335,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_annotationMapping() { + void customBridge_withParams_annotationMapping() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -369,7 +369,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_programmaticMapping() { + void customBridge_withParams_programmaticMapping() { class IndexedEntity { Integer id; WrappedValue wrap; @@ -410,7 +410,7 @@ class IndexedEntity { } @Test - public void defaultBridge_invalidFieldType() { + void defaultBridge_invalidFieldType() { @Indexed class IndexedEntity { @DocumentId @@ -437,7 +437,7 @@ class IndexedEntity { } @Test - public void customBridge_implicitFieldType_invalid() { + void customBridge_implicitFieldType_invalid() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -463,7 +463,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType_invalid() { + void customBridge_explicitFieldType_invalid() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -490,7 +490,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3243") - public void customBridge_implicitFieldType_generic() { + void customBridge_implicitFieldType_generic() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/GenericFieldIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/GenericFieldIT.java index 98f144f89e9..f4770861fe6 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/GenericFieldIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/GenericFieldIT.java @@ -32,28 +32,28 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendExtension; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class GenericFieldIT { +class GenericFieldIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void defaultAttributes() { + void defaultAttributes() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -70,7 +70,7 @@ class IndexedEntity { } @Test - public void name() { + void name() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -87,7 +87,7 @@ class IndexedEntity { } @Test - public void name_invalid_dot() { + void name_invalid_dot() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -108,7 +108,7 @@ class IndexedEntity { } @Test - public void searchable() { + void searchable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -134,7 +134,7 @@ class IndexedEntity { } @Test - public void aggregable() { + void aggregable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -160,7 +160,7 @@ class IndexedEntity { } @Test - public void customBridge_implicitFieldType() { + void customBridge_implicitFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -177,7 +177,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType() { + void customBridge_explicitFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -194,7 +194,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_annotationMapping() { + void customBridge_withParams_annotationMapping() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -230,7 +230,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_paramNotDefined() { + void customBridge_withParams_paramNotDefined() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -256,7 +256,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_paramDefinedTwice() { + void customBridge_withParams_paramDefinedTwice() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -285,7 +285,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_programmaticMapping() { + void customBridge_withParams_programmaticMapping() { class IndexedEntity { Integer id; Integer value; @@ -328,7 +328,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType_invalid() { + void customBridge_explicitFieldType_invalid() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -355,7 +355,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3243") - public void customBridge_implicitFieldType_generic() { + void customBridge_implicitFieldType_generic() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexNullAsErrorIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexNullAsErrorIT.java index cb1e575f131..c515a5485c4 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexNullAsErrorIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexNullAsErrorIT.java @@ -7,55 +7,51 @@ package org.hibernate.search.integrationtest.mapper.pojo.mapping.definition; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assume.assumeNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.lang.invoke.MethodHandles; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; import org.hibernate.search.integrationtest.mapper.pojo.testsupport.types.PropertyTypeDescriptor; import org.hibernate.search.integrationtest.mapper.pojo.testsupport.types.expectations.DefaultValueBridgeExpectations; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) -public class IndexNullAsErrorIT { +class IndexNullAsErrorIT { private static final String FIELD_NAME = DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_FIELD_NAME; private static final String FIELD_INDEXNULLAS_NAME = DefaultValueBridgeExpectations.TYPE_WITH_VALUE_BRIDGE_FIELD_INDEXNULLAS_NAME; - @Parameterized.Parameters(name = "{0}") - public static Object[] types() { + public static List params() { return PropertyTypeDescriptor.getAll().stream() .filter( type -> type.isNullable() ) - .map( type -> new Object[] { type, type.getDefaultValueBridgeExpectations() } ) - .toArray(); + .map( type -> Arguments.of( type, type.getDefaultValueBridgeExpectations() ) ) + .collect( Collectors.toList() ); } - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - private final DefaultValueBridgeExpectations expectations; - - public IndexNullAsErrorIT(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { - this.expectations = expectations; - } - - @Test - public void testParsingException() { + @ParameterizedTest(name = "{0}") + @MethodSource("params") + void testParsingException(PropertyTypeDescriptor typeDescriptor, DefaultValueBridgeExpectations expectations) { String unparsableNullAsValue = expectations.getUnparsableNullAsValue(); // Null means "there's no value I can't parse". Useful for the String type. - assumeNotNull( unparsableNullAsValue ); + assumeTrue( Objects.nonNull( unparsableNullAsValue ) ); assertThatThrownBy( () -> setupHelper.start().withConfiguration( c -> { c.addEntityType( expectations.getTypeWithValueBridge1() ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexNullAsOnNumericContainerIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexNullAsOnNumericContainerIT.java index e5e53eb6997..9b096e6a964 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexNullAsOnNumericContainerIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexNullAsOnNumericContainerIT.java @@ -15,12 +15,12 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Tests a corner case that used to not work well in Search 5 @@ -29,17 +29,17 @@ * would result in indexNullAs being interpreted as a string rather than the numeric type. */ @TestForIssue(jiraKey = "HSEARCH-2663") -public class IndexNullAsOnNumericContainerIT { +class IndexNullAsOnNumericContainerIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void test() { + void test() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b // Check that the field has type Integer and has an Integer indexNullAs value .field( "integerList", Integer.class, b2 -> b2.indexNullAs( 42 ).multiValued( true ) ) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedBaseIT.java index 30c2fc34620..e66ff7558f3 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedBaseIT.java @@ -25,36 +25,36 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.util.common.AssertionFailure; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @SuppressWarnings("unused") -public class IndexedBaseIT { +class IndexedBaseIT { - @Rule - public BackendMock defaultBackendMock = new BackendMock(); + @RegisterExtension + public BackendMock defaultBackendMock = BackendMock.create(); - @Rule - public BackendMock backend2Mock = new BackendMock(); + @RegisterExtension + public BackendMock backend2Mock = BackendMock.create(); - @Rule - public BackendMock backend3Mock = new BackendMock(); + @RegisterExtension + public BackendMock backend3Mock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), defaultBackendMock ); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper multiBackendSetupHelper; - @Rule - public StaticCounters staticCounters = new StaticCounters(); + @RegisterExtension + public StaticCounters staticCounters = StaticCounters.create(); public IndexedBaseIT() { Map namedBackendMocks = new LinkedHashMap<>(); @@ -67,7 +67,7 @@ public IndexedBaseIT() { @Test @TestForIssue(jiraKey = "HSEARCH-3705") - public void implicitIndexName_defaultEntityName() { + void implicitIndexName_defaultEntityName() { @Indexed class IndexedEntity { @DocumentId @@ -86,7 +86,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3705") - public void implicitIndexName_explicitEntityName() { + void implicitIndexName_explicitEntityName() { @Indexed class IndexedEntity { @DocumentId @@ -108,7 +108,7 @@ class IndexedEntity { } @Test - public void explicitIndexName() { + void explicitIndexName() { @Indexed(index = "explicitIndexName") class IndexedEntity { @DocumentId @@ -126,7 +126,7 @@ class IndexedEntity { } @Test - public void nonDefaultBackend() { + void nonDefaultBackend() { @Indexed(index = "index", backend = "backend2") class IndexedEntity { @DocumentId @@ -144,7 +144,7 @@ class IndexedEntity { } @Test - public void multiBackend() { + void multiBackend() { @Indexed(index = "index1", backend = "backend2") class IndexedEntity1 { @DocumentId @@ -173,7 +173,7 @@ class IndexedEntity2 { @Test @TestForIssue(jiraKey = "HSEARCH-1231") - public void inheritance() { + void inheritance() { @Indexed class IndexedEntity { @DocumentId @@ -207,7 +207,7 @@ public Integer getNumber() { @Test @TestForIssue(jiraKey = "HSEARCH-1231") - public void inheritance_abstract() { + void inheritance_abstract() { @Indexed abstract class AbstractIndexedEntity { @DocumentId @@ -250,7 +250,7 @@ public Integer getNumber2() { @Test @TestForIssue(jiraKey = "HSEARCH-1231") - public void inheritance_abstract_subclass() { + void inheritance_abstract_subclass() { @Indexed class IndexedEntity { @DocumentId @@ -304,7 +304,7 @@ public Integer getNumber2() { @Test @TestForIssue(jiraKey = "HSEARCH-1231") - public void inheritance_disabled() { + void inheritance_disabled() { @Indexed class IndexedEntity { @DocumentId @@ -335,7 +335,7 @@ public Integer getNumber() { @Test @TestForIssue(jiraKey = "HSEARCH-1231") - public void inheritance_explicitAttributes() { + void inheritance_explicitAttributes() { @Indexed(backend = "backend2", index = "parentClassIndex") class IndexedEntity { @DocumentId @@ -370,7 +370,7 @@ public Integer getNumber() { @Test @TestForIssue(jiraKey = "HSEARCH-1231") - public void inheritance_override_backend() { + void inheritance_override_backend() { @Indexed class IndexedEntity { @DocumentId @@ -405,7 +405,7 @@ public Integer getNumber() { @Test @TestForIssue(jiraKey = "HSEARCH-1231") - public void inheritance_override_index() { + void inheritance_override_index() { @Indexed(index = "parentClassIndex") class IndexedEntity { @DocumentId @@ -439,7 +439,7 @@ public Integer getNumber() { } @Test - public void error_indexedWithoutEntityMetadata() { + void error_indexedWithoutEntityMetadata() { @Indexed class IndexedWithoutEntityMetadata { @DocumentId @@ -466,7 +466,7 @@ class IndexedWithoutEntityMetadata { @Test @TestForIssue(jiraKey = "HSEARCH-3108") - public void routingBinder() { + void routingBinder() { @Indexed(routingBinder = @RoutingBinderRef(type = StaticCounterRoutingBinder.class)) class IndexedEntity { @DocumentId @@ -483,7 +483,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3108") - public void routingBinder_failure() { + void routingBinder_failure() { @Indexed(routingBinder = @RoutingBinderRef(type = FailingRoutingBinder.class)) class IndexedEntity { @DocumentId @@ -498,7 +498,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-4006") - public void moreTypesTargetSameIndex() { + void moreTypesTargetSameIndex() { @Indexed(index = "indexName") class IndexedEntityA { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedBaseIT.java index 3bfa7836b83..aff5ffb3cee 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedBaseIT.java @@ -8,7 +8,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; import java.lang.invoke.MethodHandles; import java.util.ArrayList; @@ -22,8 +21,6 @@ import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.backend.types.Searchable; -import org.hibernate.search.integrationtest.mapper.pojo.smoke.AnnotationMappingSmokeIT; -import org.hibernate.search.integrationtest.mapper.pojo.smoke.ProgrammaticMappingSmokeIT; import org.hibernate.search.integrationtest.mapper.pojo.testsupport.util.StartupStubBridge; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; import org.hibernate.search.mapper.pojo.bridge.IdentifierBridge; @@ -52,15 +49,15 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.CollectionHelper; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of the {@code @IndexedEmbedded} annotation. @@ -70,25 +67,25 @@ * (the test is named {@code ConfiguredIndexSchemaManagerNestingContextTest} at the time of this writing). *

* Does not test uses of container value extractors (for now). Some of them are tested in - * {@link AnnotationMappingSmokeIT} and {@link ProgrammaticMappingSmokeIT}. + * {@code AnnotationMappingSmokeIT} and {@code ProgrammaticMappingSmokeIT}. */ @SuppressWarnings({ "unused", "deprecation" }) // deprecated IndexedEmbedded#prefix -public class IndexedEmbeddedBaseIT { +class IndexedEmbeddedBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); @Test - public void defaultAttributes() { + void defaultAttributes() { class IndexedEmbeddedLevel2 { @GenericField String level2Property; @@ -142,7 +139,7 @@ public IndexedEntity(int id, String level1Value, String level2Value) { } @Test - public void name() { + void name() { class IndexedEmbeddedLevel1 { @GenericField String level1Property; @@ -183,7 +180,7 @@ public IndexedEntity(int id, String value) { } @Test - public void name_invalid_dot() { + void name_invalid_dot() { class IndexedEmbeddedLevel1 { @GenericField String level1Property; @@ -214,7 +211,7 @@ public IndexedEntity(int id, String value) { } @Test - public void name_andPrefix() { + void name_andPrefix() { class IndexedEmbeddedLevel1 { @GenericField String level1Property; @@ -249,7 +246,7 @@ public IndexedEntity(int id, String value) { } @Test - public void repeatedIndexedEmbedded() { + void repeatedIndexedEmbedded() { class Embedded { String forDefault; String flat; @@ -347,7 +344,7 @@ public IndexedEntity(int id, String value) { */ @Test @TestForIssue(jiraKey = "HSEARCH-3324") - public void multiValued() { + void multiValued() { class IndexedEmbeddedLevel1 { @GenericField String level1SingleValuedProperty; @@ -408,7 +405,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3324") - public void prefix_multiValued() { + void prefix_multiValued() { class IndexedEmbeddedLevel2 { String level2Property; @@ -525,7 +522,7 @@ class IndexedEntity { * Details of how filtering handles all corner cases is tested in the engine (see this class' javadoc). */ @Test - public void prefix() { + void prefix() { class IndexedEmbeddedLevel1 { @GenericField String level1Property; @@ -568,7 +565,7 @@ public IndexedEntity(int id, String level1Property) { * Details of how filtering handles all corner cases is tested in the engine (see this class' javadoc). */ @Test - public void includePaths() { + void includePaths() { class IndexedEmbeddedLevel1 { String ignoredProperty; String includedProperty; @@ -610,7 +607,7 @@ public IndexedEntity(int id, String ignoredProperty, String includedProperty) { * Details of how filtering handles all corner cases is tested in the engine (see this class' javadoc). */ @Test - public void excludePaths() { + void excludePaths() { class IndexedEmbeddedLevel1 { String ignoredProperty; String includedProperty; @@ -672,7 +669,7 @@ private void pathsWork(Class entity, Class embedded, Function entityClass, Class embeddedClass, Strin * Details of how filtering handles all corner cases is tested in the engine (see this class' javadoc). */ @Test - public void includeDepth() { + void includeDepth() { class IndexedEmbeddedLevel2 { String level2Property; @@ -818,7 +815,7 @@ public IndexedEntity(int id, String level1Value, String level2Value) { * Details of how filtering handles all corner cases is tested in the engine (see this class' javadoc). */ @Test - public void structure() { + void structure() { class IndexedEmbeddedLevel1 { @GenericField String level1Property; @@ -867,12 +864,12 @@ public IndexedEntity(int id, String level1Value) { */ @Test @TestForIssue(jiraKey = { "HSEARCH-3212", "HSEARCH-3213" }) - public void includePaths_excludesBridges() { + void includePaths_excludesBridges() { excludesBridges( true, "level1IncludedField" ); } @Test - public void excludePaths_excludesBridges() { + void excludePaths_excludesBridges() { excludesBridges( false, "location", "filteredOut", "startupStubBridgeFieldFromTypeBridge", "startupStubBridgeFieldFromPropertyBridge" @@ -950,11 +947,11 @@ public IndexedEntity(int id, String level1Property) { * We can't check the GeoPoint bridge here, because it doesn't use static counters * like our stub bridges, but we will check it isn't executed below. */ - assertEquals( 3, counters.get( filteredOutBridgeCounterKeys.instance ) ); - assertEquals( 0, counters.get( filteredOutBridgeCounterKeys.instance ) - - counters.get( filteredOutBridgeCounterKeys.close ) ); - assertEquals( 0, counters.get( filteredOutBridgeCounterKeys.instance ) - - counters.get( filteredOutBridgeCounterKeys.holderClose ) ); + assertThat( counters.get( filteredOutBridgeCounterKeys.instance ) ).isEqualTo( 3 ); + assertThat( counters.get( filteredOutBridgeCounterKeys.instance ) + - counters.get( filteredOutBridgeCounterKeys.close ) ).isZero(); + assertThat( counters.get( filteredOutBridgeCounterKeys.instance ) + - counters.get( filteredOutBridgeCounterKeys.holderClose ) ).isZero(); doTestEmbeddedRuntime( mapping, @@ -965,14 +962,14 @@ public IndexedEntity(int id, String level1Property) { ); // The bridges that were filtered out should not have been used. - assertEquals( 0, counters.get( filteredOutBridgeCounterKeys.runtimeUse ) ); - assertEquals( 0, counters.get( getLatitudeKey ) ); - assertEquals( 0, counters.get( getLongitudeKey ) ); + assertThat( counters.get( filteredOutBridgeCounterKeys.runtimeUse ) ).isZero(); + assertThat( counters.get( getLatitudeKey ) ).isZero(); + assertThat( counters.get( getLongitudeKey ) ).isZero(); } @Test @TestForIssue(jiraKey = "HSEARCH-3072") - public void targetType() { + void targetType() { abstract class IndexedEmbeddedLevel1 { public abstract String getLevel1Property(); @@ -1028,7 +1025,7 @@ public IndexedEntity(int id, String level1Value) { @Test @TestForIssue(jiraKey = "HSEARCH-3072") - public void targetType_castException() { + void targetType_castException() { abstract class IndexedEmbeddedLevel1 { public abstract String getLevel1Property(); @@ -1102,7 +1099,7 @@ public IndexedEntity(int id, String level1Value) { @Test @TestForIssue(jiraKey = "HSEARCH-4148") - public void targetType_preserveGenericTypeContext() { + void targetType_preserveGenericTypeContext() { abstract class IndexedEmbeddedLevel1 { public abstract T getLevel1Property(); @@ -1158,7 +1155,7 @@ public IndexedEntity(int id, String level1Value) { @Test @TestForIssue(jiraKey = "HSEARCH-3071") - public void includeEmbeddedObjectId() { + void includeEmbeddedObjectId() { class IndexedEmbeddedLevel1 { @DocumentId String theId; @@ -1200,7 +1197,7 @@ public IndexedEntity(int id, String level1Id) { @Test @TestForIssue(jiraKey = "HSEARCH-3071") - public void includeEmbeddedObjectId_nonEntity() { + void includeEmbeddedObjectId_nonEntity() { class IndexedEmbeddedLevel1 { @DocumentId String theId; @@ -1239,7 +1236,7 @@ public IndexedEntity(int id, String level1Id) { @Test @TestForIssue(jiraKey = "HSEARCH-3071") - public void includeEmbeddedObjectId_fieldNameConflict() { + void includeEmbeddedObjectId_fieldNameConflict() { class IndexedEmbeddedLevel1 { @DocumentId String theId; @@ -1279,7 +1276,7 @@ public IndexedEntity(int id, String level1Id) { @Test @TestForIssue(jiraKey = "HSEARCH-3071") - public void includeEmbeddedObjectId_multiValued() { + void includeEmbeddedObjectId_multiValued() { class IndexedEmbeddedLevel1 { @DocumentId String theId; @@ -1326,7 +1323,7 @@ public IndexedEntity(int id, String level1Id1, String level1Id2) { @Test @TestForIssue(jiraKey = "HSEARCH-3071") - public void includeEmbeddedObjectId_noIdentifierBridge() { + void includeEmbeddedObjectId_noIdentifierBridge() { class IndexedEmbeddedLevel1 { @DocumentId Long theId; @@ -1370,7 +1367,7 @@ public IndexedEntity(int id, Long level1Id) { @Test @TestForIssue(jiraKey = "HSEARCH-3071") - public void includeEmbeddedObjectId_identifierBinder() { + void includeEmbeddedObjectId_identifierBinder() { class IndexedEmbeddedLevel1 { @DocumentId(identifierBinder = @IdentifierBinderRef(type = MyCustomIdentifierBinder.class)) Long theId; @@ -1415,7 +1412,7 @@ public IndexedEntity(int id, Long level1Id) { @Test @TestForIssue(jiraKey = "HSEARCH-3071") - public void includeEmbeddedObjectId_identifierBridge() { + void includeEmbeddedObjectId_identifierBridge() { class IndexedEmbeddedLevel1 { @DocumentId(identifierBridge = @IdentifierBridgeRef(type = MyCustomIdentifierBinder.Bridge.class)) Long theId; @@ -1484,7 +1481,7 @@ public Long fromDocumentIdentifier(String documentIdentifier, } @Test - public void includeEmbeddedObjectId_identifierBridge_withParams_annotationMapping() { + void includeEmbeddedObjectId_identifierBridge_withParams_annotationMapping() { class IndexedEmbeddedLevel1 { @DocumentId(identifierBinder = @IdentifierBinderRef(type = ParametricBinder.class, params = @Param(name = "stringBase", value = "3"))) @@ -1529,7 +1526,7 @@ public IndexedEntity(int id, Long level1Id) { } @Test - public void includeEmbeddedObjectId_identifierBridge_withParams_programmaticMapping() { + void includeEmbeddedObjectId_identifierBridge_withParams_programmaticMapping() { class IndexedEmbeddedLevel1 { Long theId; Object containing; @@ -1628,7 +1625,7 @@ public Long fromDocumentIdentifier(String documentIdentifier, @Test @TestForIssue(jiraKey = "HSEARCH-3071") - public void includeEmbeddedObjectId_targetType() { + void includeEmbeddedObjectId_targetType() { class IndexedEmbeddedLevel1 { @DocumentId String theId; @@ -1671,7 +1668,7 @@ public IndexedEntity(int id, String level1Id) { @Test @TestForIssue(jiraKey = "HSEARCH-899") - public void invalid_wrongType() { + void invalid_wrongType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -1695,7 +1692,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-899") - public void invalid_emptyNested() { + void invalid_emptyNested() { class ValidNested { String text; @@ -1734,7 +1731,7 @@ class IndexedEntity { * (even though the property is there it is explicitly excluded by a child, so we must fail) */ @Test - public void parentIncludeChildExclude() { + void parentIncludeChildExclude() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -1808,7 +1805,7 @@ public SubSubIncluded(String subSubIncludedString) { * get excluded without complains. */ @Test - public void parentExcludeChildIncludeResultingInEmbeddedNotIncludedEntirely() { + void parentExcludeChildIncludeResultingInEmbeddedNotIncludedEntirely() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -1905,7 +1902,7 @@ model.new SubSubIncluded( "d" ) * we have multiple properties and the embedded should be included in one path, but excluded in the other */ @Test - public void parentExcludeChildIncludeResultingInEmbeddedNotIncludedEntirelyButMoreComplexModel() { + void parentExcludeChildIncludeResultingInEmbeddedNotIncludedEntirelyButMoreComplexModel() { class SubSubSubSubIncluded { @KeywordField @@ -2070,7 +2067,7 @@ public IndexedEntity(Integer id, String string, Included included) { * get excluded without complains. */ @Test - public void parentExcludeChildIncludeMultipleResultingInEmbeddedBeingIncludedPartially() { + void parentExcludeChildIncludeMultipleResultingInEmbeddedBeingIncludedPartially() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -2175,7 +2172,7 @@ model.new SubSubIncluded( "d" ) * Since parent adds a path to be excluded and child uses an include filter that explicitly includes a different field -- parent won't find a field it tries to exclude */ @Test - public void parentExcludeChildIncludeForDifferentFields() { + void parentExcludeChildIncludeForDifferentFields() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -2254,7 +2251,7 @@ public SubSubIncluded(String subSubIncludedString, String subSubOtherIncludedStr * it is ok to exclude a field in SubIncluded even if the IndexedEntity embedded doesn't need it anyway. */ @Test - public void parentIncludeChildExcludeForDifferentFieldsIsFine() { + void parentIncludeChildExcludeForDifferentFieldsIsFine() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -2352,7 +2349,7 @@ model.new Included( "b", model.new SubIncluded( } @Test - public void parentIncludeByDepthChildExcludeSomething() { + void parentIncludeByDepthChildExcludeSomething() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -2439,7 +2436,7 @@ model.new Included( "b", model.new SubIncluded( } @Test - public void parentExcludeChildExcludeSameProperty() { + void parentExcludeChildExcludeSameProperty() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -2504,7 +2501,7 @@ public SubIncluded(String subIncludedStringA, String subIncludedStringB, String } @Test - public void includeExcludeInTheSameAnnotation() { + void includeExcludeInTheSameAnnotation() { class Included { @KeywordField String includedString; @@ -2538,7 +2535,7 @@ class IndexedEntity { } @Test - public void parentExcludeByPrefix() { + void parentExcludeByPrefix() { class Included { @KeywordField String includedString; @@ -2596,7 +2593,7 @@ public IndexedEntity(Integer id, String indexedEntityString, Included included) } @Test - public void excludes() { + void excludes() { class Included { @KeywordField String a; @@ -2655,7 +2652,7 @@ public IndexedEntity(Integer id, String indexedEntityString, Included included) } @Test - public void excludePathsWithPrefixWithoutDot() { + void excludePathsWithPrefixWithoutDot() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -2757,7 +2754,7 @@ model.new EntityC( 3, "c1", "c2", "c3", "c4" ) } @Test - public void excludePathsWithPrefixWithAndWithoutDot() { + void excludePathsWithPrefixWithAndWithoutDot() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -2888,7 +2885,7 @@ model.new EntityC( 3, "c1", "c2", "c3", "c4" ) * Only full object paths are allowed in include/exclude paths. we cannot add something that ends with a prefix. */ @Test - public void excludePathsByUnterminatedPrefixIsNotAllowed() { + void excludePathsByUnterminatedPrefixIsNotAllowed() { class Model { @Indexed(index = INDEX_NAME) class EntityA { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedCycleIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedCycleIT.java index 15dd1918e60..edb2b0cec7c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedCycleIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedCycleIT.java @@ -22,37 +22,37 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test various cases of the {@code @IndexedEmbedded} leading to potential cycles, which are either broken by some * attribute of an {@code @IndexedEmbedded} or lead to an exception letting the user know that there's a cycle. */ @SuppressWarnings({ "unused", "deprecation" }) // deprecated IndexedEmbedded#prefix -public class IndexedEmbeddedCycleIT { +class IndexedEmbeddedCycleIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public StaticCounters counters = new StaticCounters(); + @RegisterExtension + public StaticCounters counters = StaticCounters.create(); @Test - public void cycle_brokenByExcludePaths() { + void cycle_brokenByExcludePaths() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -139,7 +139,7 @@ model.new EntityB( } @Test - public void cycle_brokenByExcludePathsWithPrefixEndingWithDot() { + void cycle_brokenByExcludePathsWithPrefixEndingWithDot() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -226,7 +226,7 @@ model.new EntityB( } @Test - public void cycle_brokenByExcludePathsWithPrefixWithMultipleDotsAndEndingWithDot() { + void cycle_brokenByExcludePathsWithPrefixWithMultipleDotsAndEndingWithDot() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -327,7 +327,7 @@ model.new EntityB( } @Test - public void cycle_cannotBeBrokenByExcludePathsWithPrefixNoDot() { + void cycle_cannotBeBrokenByExcludePathsWithPrefixNoDot() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -380,7 +380,7 @@ public EntityB(Integer id, String bString, EntityA a) { } @Test - public void cycle_brokenByExcludePaths_deeply() { + void cycle_brokenByExcludePaths_deeply() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -482,7 +482,7 @@ model.new EntityB( 7, "bbbb", } @Test - public void cycle_brokenByExcludePaths_deeply_nonRoot() { + void cycle_brokenByExcludePaths_deeply_nonRoot() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -589,7 +589,7 @@ model.new EntityB( 7, "bbbb", } @Test - public void cycle_brokenByExcludePathsSomewhereMidCycle_deeply_nonRoot() { + void cycle_brokenByExcludePathsSomewhereMidCycle_deeply_nonRoot() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -702,7 +702,7 @@ model.new EntityB( 7, "bbbb", } @Test - public void cycle() { + void cycle() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -737,7 +737,7 @@ class EntityB { } @Test - public void cycle_nonRoot() { + void cycle_nonRoot() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -778,7 +778,7 @@ class EntityC { } @Test - public void cycle_irrelevantExcludePaths() { + void cycle_irrelevantExcludePaths() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -815,7 +815,7 @@ class EntityB { } @Test - public void cycle_nonRoot_irrelevantExcludePaths() { + void cycle_nonRoot_irrelevantExcludePaths() { class Model { @Indexed(index = INDEX_NAME) class EntityA { @@ -859,7 +859,7 @@ class EntityC { } @Test - public void cycle_selfReferenceBreaksEventuallyWithExclude() { + void cycle_selfReferenceBreaksEventuallyWithExclude() { @Indexed(index = INDEX_NAME) class EntityA { @DocumentId @@ -929,7 +929,7 @@ public EntityA(Integer id, String string, EntityA a) { } @Test - public void cycle_selfReferenceWontBreak_excludeSomePropertyNotInCycle() { + void cycle_selfReferenceWontBreak_excludeSomePropertyNotInCycle() { @Indexed(index = INDEX_NAME) class EntityA { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedDepthIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedDepthIT.java index e07517b1dd9..965036b0baa 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedDepthIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/IndexedEmbeddedDepthIT.java @@ -12,27 +12,27 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexedEmbeddedDepthIT { +class IndexedEmbeddedDepthIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test @TestForIssue(jiraKey = "HSEARCH-1467") - public void includeDepth_differentDepths() { + void includeDepth_differentDepths() { class IndexedEmbeddedLevel2 { @GenericField String level2Property; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/KeywordFieldIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/KeywordFieldIT.java index 1149de610f0..2d52b3ad9ee 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/KeywordFieldIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/KeywordFieldIT.java @@ -30,13 +30,13 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of the {@link KeywordField} annotation. @@ -48,20 +48,20 @@ * Does not test uses of container value extractors, which are tested in {@link FieldContainerExtractorBaseIT} * (and others, see javadoc on that class). */ -public class KeywordFieldIT { +class KeywordFieldIT { private static final String INDEX_NAME = "IndexName"; private static final String NORMALIZER_NAME = "myNormalizer"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void defaultAttributes() { + void defaultAttributes() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -79,7 +79,7 @@ class IndexedEntity { } @Test - public void name() { + void name() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -96,7 +96,7 @@ class IndexedEntity { } @Test - public void name_invalid_dot() { + void name_invalid_dot() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -117,7 +117,7 @@ class IndexedEntity { } @Test - public void defaultBridge() { + void defaultBridge() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -140,7 +140,7 @@ class IndexedEntity { } @Test - public void norms() { + void norms() { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -167,7 +167,7 @@ class IndexedEntity { } @Test - public void searchable() { + void searchable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -194,7 +194,7 @@ class IndexedEntity { } @Test - public void aggregable() { + void aggregable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -220,7 +220,7 @@ class IndexedEntity { } @Test - public void customBridge_implicitFieldType() { + void customBridge_implicitFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -238,7 +238,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType() { + void customBridge_explicitFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -256,7 +256,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_annotationMapping() { + void customBridge_withParams_annotationMapping() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -290,7 +290,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_programmaticMapping() { + void customBridge_withParams_programmaticMapping() { class IndexedEntity { Integer id; WrappedValue wrap; @@ -331,7 +331,7 @@ class IndexedEntity { } @Test - public void defaultBridge_invalidFieldType() { + void defaultBridge_invalidFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -359,7 +359,7 @@ class IndexedEntity { } @Test - public void customBridge_implicitFieldType_invalid() { + void customBridge_implicitFieldType_invalid() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -386,7 +386,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType_invalid() { + void customBridge_explicitFieldType_invalid() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -414,7 +414,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3243") - public void customBridge_implicitFieldType_generic() { + void customBridge_implicitFieldType_generic() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/MarkerBindingBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/MarkerBindingBaseIT.java index 486394ce33e..2a12e14118b 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/MarkerBindingBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/MarkerBindingBaseIT.java @@ -26,27 +26,27 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.TypeBinding; import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.mapper.pojo.model.PojoModelType; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MarkerBindingBaseIT { +class MarkerBindingBaseIT { private static final String INDEX_NAME = "IndexName"; private static PojoModelType extractedModelType; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void withParams_annotationMapping() { + void withParams_annotationMapping() { backendMock.expectSchema( INDEX_NAME, b -> {} ); setupHelper.start().expectCustomBeans().setup( AnnotatedEntity.class ); backendMock.verifyExpectationsMet(); @@ -55,7 +55,7 @@ public void withParams_annotationMapping() { } @Test - public void withParams_programmaticMapping() { + void withParams_programmaticMapping() { backendMock.expectSchema( INDEX_NAME, b -> {} ); setupHelper.start() .withConfiguration( builder -> { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/NonStandardFieldIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/NonStandardFieldIT.java index 94338fc2c81..ca38391a7ac 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/NonStandardFieldIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/NonStandardFieldIT.java @@ -20,14 +20,14 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.NonStandardField; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendExtension; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of the {@link NonStandardField} annotation. @@ -39,19 +39,19 @@ * Does not test uses of container value extractors, which are tested in {@link FieldContainerExtractorBaseIT} * (and others, see javadoc on that class). */ -public class NonStandardFieldIT { +class NonStandardFieldIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void defaultAttributes() { + void defaultAttributes() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -68,7 +68,7 @@ class IndexedEntity { } @Test - public void name() { + void name() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -86,7 +86,7 @@ class IndexedEntity { } @Test - public void name_invalid_dot() { + void name_invalid_dot() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -108,7 +108,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType() { + void customBridge_explicitFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -125,7 +125,7 @@ class IndexedEntity { } @Test - public void defaultBridge_invalidFieldType() { + void defaultBridge_invalidFieldType() { @Indexed class IndexedEntity { @DocumentId @@ -150,7 +150,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType_invalid() { + void customBridge_explicitFieldType_invalid() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -175,7 +175,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3243") - public void customBridge_implicitFieldType_generic() { + void customBridge_implicitFieldType_generic() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PojoStandaloneSearchMappingConfigurerIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PojoStandaloneSearchMappingConfigurerIT.java index 8918af95133..7a7990f4512 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PojoStandaloneSearchMappingConfigurerIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PojoStandaloneSearchMappingConfigurerIT.java @@ -15,24 +15,24 @@ import org.hibernate.search.mapper.pojo.standalone.cfg.StandalonePojoMapperSettings; import org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurationContext; import org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurer; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class PojoStandaloneSearchMappingConfigurerIT { +class PojoStandaloneSearchMappingConfigurerIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void none() { + void none() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "annotationMapped", String.class ) ); @@ -43,7 +43,7 @@ public void none() { } @Test - public void single() { + void single() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "annotationMapped", String.class ) .field( "nonAnnotationMapped1", String.class ) @@ -68,7 +68,7 @@ public void configure(StandalonePojoMappingConfigurationContext context) { @Test @TestForIssue(jiraKey = "HSEARCH-4594") - public void multiple() { + void multiple() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "annotationMapped", String.class ) .field( "nonAnnotationMapped1", String.class ) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorBaseIT.java index e31c5e4686b..aad83fa1249 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorBaseIT.java @@ -27,23 +27,23 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-3927") -public class ProjectionConstructorBaseIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorBaseIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void typeLevelAnnotation() { + void typeLevelAnnotation() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -85,7 +85,7 @@ public MyProjection(String text, Integer integer) { } @Test - public void typeLevelAnnotation_multipleConstructors() { + void typeLevelAnnotation_multipleConstructors() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -123,7 +123,7 @@ public MyProjection(String text, Integer integer, String somethingElse) { } @Test - public void constructorLevelAnnotation() { + void constructorLevelAnnotation() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -175,7 +175,7 @@ public MyProjection(String text, Integer integer, String somethingElse) { } @Test - public void abstractType() { + void abstractType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -214,7 +214,7 @@ public MyAbstractProjection(String text, Integer integer, String somethingElse) } @Test - public void entityAndProjection() { + void entityAndProjection() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -253,7 +253,7 @@ public IndexedEntity(String text, Integer integer) { } @Test - public void noArgConstructor() { + void noArgConstructor() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -300,7 +300,7 @@ public MyProjection(String text, Integer integer) { } @Test - public void noProjectionConstructor() { + void noProjectionConstructor() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -343,7 +343,7 @@ public MyNonProjection(String text, Integer integer) { // This can happen if the class is not included in any Jandex index on startup. @Test - public void annotationNotProcessed() { + void annotationNotProcessed() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -389,7 +389,7 @@ public MyProjection(String text, Integer integer) { } @Test - public void inheritance_sameConstructorParameters_subclassOnlyWithProjectionConstructor() { + void inheritance_sameConstructorParameters_subclassOnlyWithProjectionConstructor() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -462,7 +462,7 @@ public MyProjectionSubclass(String text, Integer integer, String somethingElse) } @Test - public void inheritance_sameConstructorParameters_superclassOnlyWithProjectionConstructor() { + void inheritance_sameConstructorParameters_superclassOnlyWithProjectionConstructor() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -535,7 +535,7 @@ public MyNonProjectionSubclass(String text, Integer integer, String somethingEls } @Test - public void inheritance_sameConstructorParameters_bothClassesWithProjectionConstructor() { + void inheritance_sameConstructorParameters_bothClassesWithProjectionConstructor() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -620,7 +620,7 @@ public MyProjectionSubclass(String text, Integer integer, String somethingElse) // to the object field, while usually projection factories expect absolute paths // (if everything works correctly they don't in this case, though). @Test - public void nonRoot() { + void nonRoot() { class Contained { @DocumentId public Integer id; @@ -676,7 +676,7 @@ public MyProjection(String text, Integer integer) { } @Test - public void incompatibleProjectionWithExtraPropertiesMissing() { + void incompatibleProjectionWithExtraPropertiesMissing() { class Author { private Integer id; @@ -767,7 +767,7 @@ class MyProjectionBook { } @Test - public void multipleParameterProjectionAnnotations() { + void multipleParameterProjectionAnnotations() { class Model { @Indexed(index = INDEX_NAME) class IndexedEntity { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorCompositeProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorCompositeProjectionIT.java index 079580eb6a5..2a5e6f9dae3 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorCompositeProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorCompositeProjectionIT.java @@ -25,18 +25,18 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorCompositeProjectionIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorCompositeProjectionIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void noArg() { + void noArg() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -101,7 +101,7 @@ public MyProjection(String text, @CompositeProjection MyInnerProjection composit } @Test - public void invalidType() { + void invalidType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -149,7 +149,7 @@ public MyProjection(@CompositeProjection MyNonProjection composite) { } @Test - public void inObjectField() { + void inObjectField() { class Contained { @DocumentId public Integer id; @@ -242,7 +242,7 @@ public MyProjection(String text, MyInnerProjectionLevel1 contained) { } @Test - public void multiValued() { + void multiValued() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorDocumentReferenceProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorDocumentReferenceProjectionIT.java index e093cf74728..58d66c47f1e 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorDocumentReferenceProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorDocumentReferenceProjectionIT.java @@ -24,18 +24,18 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorDocumentReferenceProjectionIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorDocumentReferenceProjectionIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void noArg() { + void noArg() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -77,7 +77,7 @@ public MyProjection(@DocumentReferenceProjection DocumentReference documentRefer } @Test - public void supertype() { + void supertype() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -119,7 +119,7 @@ public MyProjection(@DocumentReferenceProjection Object documentReference) { } @Test - public void invalidType() { + void invalidType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorEntityProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorEntityProjectionIT.java index 72d1006411d..f2b582bc297 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorEntityProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorEntityProjectionIT.java @@ -28,21 +28,21 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorEntityProjectionIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorEntityProjectionIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); protected final StubLoadingContext loadingContext = new StubLoadingContext(); - @Before - public void persistEntities() { + @BeforeEach + void persistEntities() { loadingContext.persistenceMap( IndexedEntity.PERSISTENCE_KEY ) .put( 1, new IndexedEntity( 1, new Contained( 11 ) ) ); loadingContext.persistenceMap( IndexedEntity.PERSISTENCE_KEY ) @@ -52,7 +52,7 @@ public void persistEntities() { } @Test - public void noArg() { + void noArg() { class MyProjection { public final IndexedEntity entity; @@ -88,7 +88,7 @@ public MyProjection(@EntityProjection IndexedEntity entity) { } @Test - public void supertype() { + void supertype() { class MyProjection { public final Object entity; @@ -124,7 +124,7 @@ public MyProjection(@EntityProjection Object entity) { } @Test - public void invalidType() { + void invalidType() { class MyProjection { public final Integer entity; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorEntityReferenceProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorEntityReferenceProjectionIT.java index 34ca4eab1bd..445810f2cae 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorEntityReferenceProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorEntityReferenceProjectionIT.java @@ -25,18 +25,18 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorEntityReferenceProjectionIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorEntityReferenceProjectionIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void noArg() { + void noArg() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -78,7 +78,7 @@ public MyProjection(@EntityReferenceProjection EntityReference entityReference) } @Test - public void supertype() { + void supertype() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -120,7 +120,7 @@ public MyProjection(@EntityReferenceProjection Object entityReference) { } @Test - public void invalidType() { + void invalidType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorFieldProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorFieldProjectionIT.java index 766b963bae1..5654ea03c0c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorFieldProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorFieldProjectionIT.java @@ -30,18 +30,18 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorFieldProjectionIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorFieldProjectionIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void noArg() { + void noArg() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -83,7 +83,7 @@ public MyProjection(@FieldProjection String text) { } @Test - public void path() { + void path() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -125,7 +125,7 @@ public MyProjection(@FieldProjection(path = "myText") String text) { } @Test - public void valueConvert() { + void valueConvert() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -171,7 +171,7 @@ enum MyEnum { } @Test - public void supertype() { + void supertype() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -213,7 +213,7 @@ public MyProjection(@FieldProjection Object text) { } @Test - public void primitiveType() { + void primitiveType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -255,7 +255,7 @@ public MyProjection(@FieldProjection int integer) { } @Test - public void inObjectField() { + void inObjectField() { class Contained { @DocumentId public Integer id; @@ -325,7 +325,7 @@ public MyProjection(@FieldProjection String text, MyInnerProjection contained) { } @Test - public void inObjectField_filteredOut() { + void inObjectField_filteredOut() { class Contained { @DocumentId public Integer id; @@ -398,7 +398,7 @@ public MyProjection(@FieldProjection String text, } @Test - public void inObjectField_multiValued_filteredOut() { + void inObjectField_multiValued_filteredOut() { class Contained { @DocumentId public Integer id; @@ -471,7 +471,7 @@ public MyProjection(@FieldProjection String text, } @Test - public void multiValued_list() { + void multiValued_list() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -522,7 +522,7 @@ public MyProjection(@FieldProjection List text, @FieldProjection List text, @FieldProjection C } @Test - public void multiValued_iterable() { + void multiValued_iterable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -624,7 +624,7 @@ public MyProjection(@FieldProjection Iterable text, @FieldProjection Ite } @Test - public void multiValued_set() { + void multiValued_set() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorHighlightProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorHighlightProjectionIT.java index a51cfa588a4..70efe54ff55 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorHighlightProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorHighlightProjectionIT.java @@ -27,18 +27,18 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorHighlightProjectionIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorHighlightProjectionIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void noArg() { + void noArg() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -80,7 +80,7 @@ public MyProjection(@HighlightProjection List text) { } @Test - public void path() { + void path() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -122,7 +122,7 @@ public MyProjection(@HighlightProjection(path = "myText") List text) { } @Test - public void highlighter() { + void highlighter() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -165,7 +165,7 @@ public MyProjection(@HighlightProjection(highlighter = "foo") List text) } @Test - public void superType() { + void superType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -207,7 +207,7 @@ public MyProjection(@HighlightProjection List text) { } @Test - public void singleValued() { + void singleValued() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -239,7 +239,7 @@ public MyProjection(@HighlightProjection String text) { // Technically this is not supported on the backend side, // but we'll test it just to be sure the mapper side works. @Test - public void inObjectField() { + void inObjectField() { class Contained { @DocumentId public Integer id; @@ -311,7 +311,7 @@ public MyProjection(@HighlightProjection List text, MyInnerProjection co } @Test - public void collection() { + void collection() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -353,7 +353,7 @@ public MyProjection(@HighlightProjection Collection text) { } @Test - public void iterable() { + void iterable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -395,7 +395,7 @@ public MyProjection(@HighlightProjection Iterable text) { } @Test - public void set() { + void set() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -425,7 +425,7 @@ public MyProjection(@HighlightProjection Set text) { } @Test - public void invalidElementType() { + void invalidElementType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorIdProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorIdProjectionIT.java index 7836fe6410b..fb38125f088 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorIdProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorIdProjectionIT.java @@ -19,18 +19,18 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorIdProjectionIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorIdProjectionIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void noArg() { + void noArg() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -74,7 +74,7 @@ public MyProjection(@IdProjection Integer identifier) { } @Test - public void supertype() { + void supertype() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -116,7 +116,7 @@ public MyProjection(@IdProjection Object id) { } @Test - public void primitiveType() { + void primitiveType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorInnerInferredIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorInnerInferredIT.java index 48580939d6f..609b2eee674 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorInnerInferredIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorInnerInferredIT.java @@ -27,18 +27,18 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-3927") -public class ProjectionConstructorInnerInferredIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorInnerInferredIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void value() { + void value() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -85,7 +85,7 @@ public MyProjection(String text, Integer integer) { } @Test - public void value_multiValued_list() { + void value_multiValued_list() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -136,7 +136,7 @@ public MyProjection(List text, List integer) { } @Test - public void value_multiValued_collection() { + void value_multiValued_collection() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -187,7 +187,7 @@ public MyProjection(Collection text, Collection integer) { } @Test - public void value_multiValued_iterable() { + void value_multiValued_iterable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -238,7 +238,7 @@ public MyProjection(Iterable text, Iterable integer) { } @Test - public void value_multiValued_set() { + void value_multiValued_set() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -275,7 +275,7 @@ public MyProjection(Set text, List integer) { } @Test - public void object() { + void object() { class Contained { @DocumentId public Integer id; @@ -350,7 +350,7 @@ public MyProjection(String text, MyInnerProjection contained) { // If an inner projection type is not included in any Jandex index on startup, // Hibernate Search can still get on its feet thanks to annotated type discovery. @Test - public void object_annotatedTypeDiscovery() { + void object_annotatedTypeDiscovery() { class Contained { @DocumentId public Integer id; @@ -425,7 +425,7 @@ public MyProjection(String text, MyInnerProjection contained) { } @Test - public void object_multiValued_list() { + void object_multiValued_list() { class Contained { @DocumentId public Integer id; @@ -515,7 +515,7 @@ public MyProjection(String text, List contained) { } @Test - public void object_multiValued_collection() { + void object_multiValued_collection() { class Contained { @DocumentId public Integer id; @@ -605,7 +605,7 @@ public MyProjection(String text, Collection contained) { } @Test - public void object_multiValued_iterable() { + void object_multiValued_iterable() { class Contained { @DocumentId public Integer id; @@ -695,7 +695,7 @@ public MyProjection(String text, Iterable contained) { } @Test - public void object_multiValued_set() { + void object_multiValued_set() { class Contained { @DocumentId public Integer id; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionCycleIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionCycleIT.java index 4273578126a..12c76367f80 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionCycleIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionCycleIT.java @@ -23,20 +23,20 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4725") -public class ProjectionConstructorObjectProjectionCycleIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorObjectProjectionCycleIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ) // We don't care about reindexing here and don't want to configure association inverse sides .disableAssociationReindexing(); @Test - public void actualCycle_direct() { + void actualCycle_direct() { class Model { @Indexed(index = INDEX_NAME) class Level1 { @@ -103,7 +103,7 @@ public ProjectionLevel2(String text, ProjectionLevel1 level1) { } @Test - public void brokenCycle_includePaths() { + void brokenCycle_includePaths() { class Model { @Indexed(index = INDEX_NAME) class Level1 { @@ -177,7 +177,7 @@ model.new ProjectionLevel1( "result2_level2_level1", null ) ) ) } @Test - public void brokenCycle_excludePaths() { + void brokenCycle_excludePaths() { class Model { @Indexed(index = INDEX_NAME) class Level1 { @@ -251,7 +251,7 @@ model.new ProjectionLevel1( "result2_level2_level1", null ) ) ) } @Test - public void brokenCycle_includeDepth() { + void brokenCycle_includeDepth() { class Model { @Indexed(index = INDEX_NAME) class Level1 { @@ -325,7 +325,7 @@ model.new ProjectionLevel1( "result2_level2_level1", null ) ) ) } @Test - public void actualCycle_indirect_noFilter() { + void actualCycle_indirect_noFilter() { class Model { @Indexed(index = INDEX_NAME) class Level1 { @@ -415,7 +415,7 @@ public ProjectionLevel3(String text, ProjectionLevel1 level1) { } @Test - public void actualCycle_buried_noFilter() { + void actualCycle_buried_noFilter() { class Model { @Indexed(index = INDEX_NAME) class Level1 { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionIT.java index 9b6d3a0d35b..39a1efb0fba 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorObjectProjectionIT.java @@ -28,20 +28,20 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorObjectProjectionIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorObjectProjectionIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ) // We don't care about reindexing here and don't want to configure association inverse sides .disableAssociationReindexing(); @Test - public void noArg() { + void noArg() { class Contained { @DocumentId public Integer id; @@ -111,7 +111,7 @@ public MyProjection(String text, @ObjectProjection MyInnerProjection contained) } @Test - public void path() { + void path() { class Contained { @DocumentId public Integer id; @@ -182,7 +182,7 @@ public MyProjection(String text, } @Test - public void invalidType() { + void invalidType() { class Contained { @DocumentId public Integer id; @@ -238,7 +238,7 @@ public MyProjection(@ObjectProjection MyNonProjection contained) { } @Test - public void nonMatchingIncludePaths() { + void nonMatchingIncludePaths() { class Contained { @DocumentId public Integer id; @@ -294,7 +294,7 @@ public MyProjection(String text, } @Test - public void nonMatchingExcludePaths() { + void nonMatchingExcludePaths() { class Contained { @DocumentId public Integer id; @@ -350,7 +350,7 @@ public MyProjection(String text, } @Test - public void inObjectField() { + void inObjectField() { class ContainedLevel2 { @DocumentId public Integer id; @@ -453,7 +453,7 @@ public MyProjection(String text, @ObjectProjection MyInnerProjectionLevel1 conta } @Test - public void inObjectField_filteredOut() { + void inObjectField_filteredOut() { class ContainedLevel2 { @DocumentId public Integer id; @@ -545,7 +545,7 @@ public MyProjection(String text, } @Test - public void inObjectField_multiValued_filteredOut() { + void inObjectField_multiValued_filteredOut() { class ContainedLevel2 { @DocumentId public Integer id; @@ -637,7 +637,7 @@ public MyProjection(String text, } @Test - public void multiValued_list() { + void multiValued_list() { class Contained { @DocumentId public Integer id; @@ -727,7 +727,7 @@ public MyProjection(String text, @ObjectProjection List conta } @Test - public void multiValued_collection() { + void multiValued_collection() { class Contained { @DocumentId public Integer id; @@ -817,7 +817,7 @@ public MyProjection(String text, @ObjectProjection Collection } @Test - public void multiValued_iterable() { + void multiValued_iterable() { class Contained { @DocumentId public Integer id; @@ -907,7 +907,7 @@ public MyProjection(String text, @ObjectProjection Iterable c } @Test - public void multiValued_set() { + void multiValued_set() { class Contained { @DocumentId public Integer id; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorProjectionBindingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorProjectionBindingIT.java index 7bc93318dcf..7fb72889645 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorProjectionBindingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorProjectionBindingIT.java @@ -27,28 +27,28 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of the {@link ProjectionBinding} annotation. */ @SuppressWarnings("unused") @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorProjectionBindingIT { +class ProjectionConstructorProjectionBindingIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -57,7 +57,7 @@ protected final ProjectionFinalStep dummyProjectionForEnclosingClassInstance( } @Test - public void simple() { + void simple() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -124,7 +124,7 @@ public void bind(ProjectionBindingContext context) { } @Test - public void missingBinderReference() { + void missingBinderReference() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -154,7 +154,7 @@ public MyProjection(@ProjectionBinding(binder = @ProjectionBinderRef) String tex } @Test - public void params() { + void params() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -213,7 +213,7 @@ public MyProjection(@ProjectionBinding(binder = @ProjectionBinderRef(type = Para } @Test - public void params_paramNotDefined() { + void params_paramNotDefined() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -244,7 +244,7 @@ public MyProjection(@ProjectionBinding(binder = @ProjectionBinderRef(type = Para } @Test - public void params_paramDefinedTwice() { + void params_paramDefinedTwice() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -280,7 +280,7 @@ public MyProjection(@ProjectionBinding(binder = @ProjectionBinderRef(type = Para } @Test - public void params_programmaticMapping() { + void params_programmaticMapping() { @Indexed(index = INDEX_NAME) class IndexedEntity { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorScoreProjectionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorScoreProjectionIT.java index 8e90b50cf6c..f2a269cd559 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorScoreProjectionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorScoreProjectionIT.java @@ -22,18 +22,18 @@ import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-4574") -public class ProjectionConstructorScoreProjectionIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorScoreProjectionIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void noArg() { + void noArg() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -75,7 +75,7 @@ public MyProjection(@ScoreProjection Float score) { } @Test - public void supertype() { + void supertype() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -117,7 +117,7 @@ public MyProjection(@ScoreProjection Object score) { } @Test - public void primitiveType() { + void primitiveType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -159,7 +159,7 @@ public MyProjection(@ScoreProjection float score) { } @Test - public void invalidType() { + void invalidType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBindingBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBindingBaseIT.java index 4ba775bcef3..308fb8fdea7 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBindingBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBindingBaseIT.java @@ -27,27 +27,27 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of the {@link PropertyBinding} annotation. */ @SuppressWarnings("unused") @TestForIssue(jiraKey = "HSEARCH-3135") -public class PropertyBindingBaseIT { +class PropertyBindingBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -55,7 +55,7 @@ public class PropertyBindingBaseIT { * Basic test checking that a simple type binding will be applied as expected. */ @Test - public void simple() { + void simple() { backendMock.expectSchema( INDEX_NAME, b -> b.field( "myText", String.class ) ); @@ -88,7 +88,7 @@ public void bind(PropertyBindingContext context) { } @Test - public void missingBinderReference() { + void missingBinderReference() { @Indexed class IndexedEntity { @DocumentId @@ -109,7 +109,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_annotationMapping() { + void customBridge_withParams_annotationMapping() { backendMock.expectSchema( INDEX_NAME, b -> { b.field( "sum", Integer.class ); b.field( "diff", Integer.class ); @@ -136,7 +136,7 @@ public void customBridge_withParams_annotationMapping() { } @Test - public void customBridge_withParams_paramNotDefined() { + void customBridge_withParams_paramNotDefined() { assertThatThrownBy( () -> setupHelper.start().expectCustomBeans().setup( AnnotatedNoParamEntity.class ) ) @@ -149,7 +149,7 @@ public void customBridge_withParams_paramNotDefined() { } @Test - public void customBridge_withParams_paramDefinedTwice() { + void customBridge_withParams_paramDefinedTwice() { assertThatThrownBy( () -> setupHelper.start().expectCustomBeans().setup( AnnotatedSameParamTwiceEntity.class ) ) @@ -164,7 +164,7 @@ public void customBridge_withParams_paramDefinedTwice() { } @Test - public void customBridge_withParams_programmaticMapping() { + void customBridge_withParams_programmaticMapping() { backendMock.expectSchema( INDEX_NAME, b -> { b.field( "sum", Integer.class ); b.field( "diff", Integer.class ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBridgeBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBridgeBaseIT.java index 18463659280..8461395c1f9 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBridgeBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBridgeBaseIT.java @@ -17,7 +17,6 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.search.predicate.definition.PredicateDefinition; -import org.hibernate.search.integrationtest.mapper.pojo.mapping.annotation.processing.CustomPropertyMappingAnnotationBaseIT; import org.hibernate.search.mapper.pojo.bridge.PropertyBridge; import org.hibernate.search.mapper.pojo.bridge.binding.PropertyBindingContext; import org.hibernate.search.mapper.pojo.bridge.mapping.annotation.PropertyBinderRef; @@ -39,30 +38,30 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.AssertionFailure; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of (custom) property bridges. *

* Does not test reindexing in depth; this is tested in {@code AutomaticIndexing*} tests in the ORM mapper. *

- * Does not test custom annotations; this is tested in {@link CustomPropertyMappingAnnotationBaseIT}. + * Does not test custom annotations; this is tested in {@code CustomPropertyMappingAnnotationBaseIT}. */ @SuppressWarnings("unused") -public class PropertyBridgeBaseIT { +class PropertyBridgeBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -74,7 +73,7 @@ public class PropertyBridgeBaseIT { */ @Test @TestForIssue(jiraKey = { "HSEARCH-2055", "HSEARCH-2641" }) - public void accessors() { + void accessors() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -139,7 +138,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitDependencies() { + void explicitDependencies() { class Contained { String stringProperty; } @@ -222,7 +221,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitDependencies_inacessibleObject() { + void explicitDependencies_inacessibleObject() { backendMock.expectSchema( INDEX_NAME, b -> b.field( "someField", String.class, b2 -> { b2.analyzerName( "myAnalyzer" ); // For HSEARCH-2641 } ) @@ -281,7 +280,7 @@ enum MyEnum { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitDependencies_error_invalidProperty() { + void explicitDependencies_error_invalidProperty() { class Contained { String stringProperty; } @@ -314,7 +313,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitDependencies_error_invalidContainerExtractorPath() { + void explicitDependencies_error_invalidContainerExtractorPath() { class Contained { String stringProperty; } @@ -358,7 +357,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing() { + void explicitReindexing() { backendMock.expectSchema( INDEX_NAME, b -> b.field( "someField", String.class, b2 -> { b2.analyzerName( "myAnalyzer" ); // For HSEARCH-2641 } ) @@ -458,7 +457,7 @@ static class NotEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_use_invalidProperty() { + void explicitReindexing_error_use_invalidProperty() { assertThatThrownBy( () -> setupHelper.start().withConfiguration( b -> b.programmaticMapping().type( PropertyBridgeExplicitIndexingClasses.IndexedEntity.class ) @@ -489,7 +488,7 @@ public void explicitReindexing_error_use_invalidProperty() { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_fromOtherEntity_invalidProperty() { + void explicitReindexing_error_fromOtherEntity_invalidProperty() { assertThatThrownBy( () -> setupHelper.start().withConfiguration( b -> b.programmaticMapping().type( PropertyBridgeExplicitIndexingClasses.IndexedEntity.class ) @@ -519,7 +518,7 @@ public void explicitReindexing_error_fromOtherEntity_invalidProperty() { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_fromOtherEntity_invalidContainerExtractorPath() { + void explicitReindexing_error_fromOtherEntity_invalidContainerExtractorPath() { assertThatThrownBy( () -> setupHelper.start().withConfiguration( b -> b.programmaticMapping().type( PropertyBridgeExplicitIndexingClasses.IndexedEntity.class ) @@ -553,7 +552,7 @@ public void explicitReindexing_error_fromOtherEntity_invalidContainerExtractorPa @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_fromOtherEntity_bridgedElementNotEntityType() { + void explicitReindexing_error_fromOtherEntity_bridgedElementNotEntityType() { assertThatThrownBy( () -> setupHelper.start().withConfiguration( b -> b.programmaticMapping().type( PropertyBridgeExplicitIndexingClasses.IndexedEntity.class ) @@ -588,7 +587,7 @@ public void explicitReindexing_error_fromOtherEntity_bridgedElementNotEntityType @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_fromOtherEntity_otherEntityTypeNotEntityType() { + void explicitReindexing_error_fromOtherEntity_otherEntityTypeNotEntityType() { assertThatThrownBy( () -> setupHelper.start().withConfiguration( b -> b.programmaticMapping().type( PropertyBridgeExplicitIndexingClasses.IndexedEntity.class ) @@ -622,7 +621,7 @@ public void explicitReindexing_error_fromOtherEntity_otherEntityTypeNotEntityTyp @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_fromOtherEntity_inverseAssociationPathTargetsWrongType() { + void explicitReindexing_error_fromOtherEntity_inverseAssociationPathTargetsWrongType() { assertThatThrownBy( () -> setupHelper.start().withConfiguration( b -> b.programmaticMapping().type( PropertyBridgeExplicitIndexingClasses.IndexedEntity.class ) @@ -658,7 +657,7 @@ public void explicitReindexing_error_fromOtherEntity_inverseAssociationPathTarge @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void missingDependencyDeclaration() { + void missingDependencyDeclaration() { class Contained { String stringProperty; } @@ -694,7 +693,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void inconsistentDependencyDeclaration() { + void inconsistentDependencyDeclaration() { class Contained { String stringProperty; } @@ -733,7 +732,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") @SuppressWarnings({ "unchecked", "rawtypes" }) - public void useRootOnly() { + void useRootOnly() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -796,7 +795,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3324") - public void field() { + void field() { class Contained { } @Indexed(index = INDEX_NAME) @@ -836,7 +835,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3324") - public void objectField() { + void objectField() { class Contained { } @Indexed(index = INDEX_NAME) @@ -886,7 +885,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3273") - public void fieldTemplate() { + void fieldTemplate() { class Contained { } @Indexed(index = INDEX_NAME) @@ -931,7 +930,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3273") - public void objectFieldTemplate() { + void objectFieldTemplate() { class Contained { } @Indexed(index = INDEX_NAME) @@ -985,7 +984,7 @@ class IndexedEntity { } @Test - public void accessors_incompatibleRequestedType() { + void accessors_incompatibleRequestedType() { @Indexed class IndexedEntity { @DocumentId @@ -1019,7 +1018,7 @@ public void write(DocumentElement target, Object bridgedElement, PropertyBridgeW } @Test - public void propertyBridge_invalidInputType() { + void propertyBridge_invalidInputType() { @Indexed class IndexedEntity { @DocumentId @@ -1062,7 +1061,7 @@ public void bind(PropertyBindingContext context) { * Test for backward compatibility with 6.0.0.CR1 APIs */ @Test - public void propertyBridge_noGenericType() { + void propertyBridge_noGenericType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -1118,7 +1117,7 @@ public void bind(PropertyBindingContext context) { */ @Test @TestForIssue(jiraKey = "HSEARCH-4166") - public void namedPredicate() { + void namedPredicate() { class Contained { } @Indexed(index = INDEX_NAME) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBridgeRuntimePolymorphismHackIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBridgeRuntimePolymorphismHackIT.java index c0f30af5c12..82392dfce35 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBridgeRuntimePolymorphismHackIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/PropertyBridgeRuntimePolymorphismHackIT.java @@ -27,30 +27,30 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * See https://discourse.hibernate.org/t/propertybinder-for-base-type-reports-no-children-property-found-in-parent-class/5493/2 */ @TestForIssue(jiraKey = "HSEARCH-4491") -public class PropertyBridgeRuntimePolymorphismHackIT { +class PropertyBridgeRuntimePolymorphismHackIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void explicitReindexing_hack_runtimePolymorphism() { + void explicitReindexing_hack_runtimePolymorphism() { backendMock.expectSchema( INDEX_NAME, b -> b.field( "someField", String.class ) ); SearchMapping mapping = setupHelper.start() diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/RoutingBridgeBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/RoutingBridgeBaseIT.java index 66ddca4a799..d7a8122707d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/RoutingBridgeBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/RoutingBridgeBaseIT.java @@ -28,14 +28,14 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.AssertionFailure; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of (custom) routing bridges. @@ -45,19 +45,19 @@ */ @SuppressWarnings("unused") @TestForIssue(jiraKey = "HSEARCH-3108") -public class RoutingBridgeBaseIT { +class RoutingBridgeBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void invalidTypeForRoutingBridge() { + void invalidTypeForRoutingBridge() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -80,7 +80,7 @@ class IndexedEntity { } @Test - public void currentRoute_missing() { + void currentRoute_missing() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -140,7 +140,7 @@ public void previousRoutes(DocumentRoutes routes, Object entityIdentifier, Index } @Test - public void previousRoutes_missing() { + void previousRoutes_missing() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -215,7 +215,7 @@ public void previousRoutes(DocumentRoutes routes, Object entityIdentifier, Index } @Test - public void currentRoute_multiple() { + void currentRoute_multiple() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -275,7 +275,7 @@ public void previousRoutes(DocumentRoutes routes, Object entityIdentifier, Index } @Test - public void accessors() { + void accessors() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -354,7 +354,7 @@ public void previousRoutes(DocumentRoutes routes, Object entityIdentifier, } @Test - public void accessors_incompatibleRequestedType() { + void accessors_incompatibleRequestedType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -385,7 +385,7 @@ class IndexedEntity { * Note that reindexing is tested in depth in the ORM mapper integration tests. */ @Test - public void explicitDependencies() { + void explicitDependencies() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -463,7 +463,7 @@ public void previousRoutes(DocumentRoutes routes, Object entityIdentifier, } @Test - public void explicitDependencies_error_invalidProperty() { + void explicitDependencies_error_invalidProperty() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -488,7 +488,7 @@ class IndexedEntity { } @Test - public void missingDependencyDeclaration() { + void missingDependencyDeclaration() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -515,7 +515,7 @@ class IndexedEntity { } @Test - public void inconsistentDependencyDeclaration() { + void inconsistentDependencyDeclaration() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -544,7 +544,7 @@ class IndexedEntity { } @Test - public void useRootOnly() { + void useRootOnly() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -640,7 +640,7 @@ public void previousRoutes(DocumentRoutes routes, Object entityIdentifier, T ind } @Test - public void params_annotationMapping() { + void params_annotationMapping() { backendMock.expectSchema( INDEX_NAME, b -> {} ); SearchMapping mapping = setupHelper.start().expectCustomBeans().setup( AnnotatedRoutedEntity.class ); backendMock.verifyExpectationsMet(); @@ -657,7 +657,7 @@ public void params_annotationMapping() { } @Test - public void params_paramNotDefined() { + void params_paramNotDefined() { assertThatThrownBy( () -> setupHelper.start().expectCustomBeans().setup( AnnotatedRoutedNoParamEntity.class ) ) @@ -669,7 +669,7 @@ public void params_paramNotDefined() { } @Test - public void params_paramDefinedTwice() { + void params_paramDefinedTwice() { assertThatThrownBy( () -> setupHelper.start().expectCustomBeans().setup( AnnotatedRoutedSameParamTwiceEntity.class ) ) @@ -683,7 +683,7 @@ public void params_paramDefinedTwice() { } @Test - public void params_programmaticMapping() { + void params_programmaticMapping() { backendMock.expectSchema( INDEX_NAME, b -> {} ); SearchMapping mapping = setupHelper.start().expectCustomBeans() .withConfiguration( builder -> { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ScaledNumberFieldIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ScaledNumberFieldIT.java index cdef9f77ceb..aaaabbe1281 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ScaledNumberFieldIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ScaledNumberFieldIT.java @@ -32,27 +32,27 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ScaledNumberFieldIT { +class ScaledNumberFieldIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void defaultAttributes() { + void defaultAttributes() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -69,7 +69,7 @@ class IndexedEntity { } @Test - public void name() { + void name() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -86,7 +86,7 @@ class IndexedEntity { } @Test - public void name_invalid_dot() { + void name_invalid_dot() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -107,7 +107,7 @@ class IndexedEntity { } @Test - public void validDecimalScales_bigDecimals() { + void validDecimalScales_bigDecimals() { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -131,7 +131,7 @@ class IndexedEntity { } @Test - public void validDecimalScales_bigIntegers() { + void validDecimalScales_bigIntegers() { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -155,7 +155,7 @@ class IndexedEntity { } @Test - public void defaultBridge_invalidFieldType() { + void defaultBridge_invalidFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -184,7 +184,7 @@ class IndexedEntity { } @Test - public void searchable() { + void searchable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @@ -211,7 +211,7 @@ class IndexedEntity { } @Test - public void aggregable() { + void aggregable() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -237,7 +237,7 @@ class IndexedEntity { } @Test - public void customBridge_implicitFieldType() { + void customBridge_implicitFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -254,7 +254,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType() { + void customBridge_explicitFieldType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -272,7 +272,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_annotationMapping() { + void customBridge_withParams_annotationMapping() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -316,7 +316,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_programmaticMapping() { + void customBridge_withParams_programmaticMapping() { class IndexedEntity { Integer id; WrappedValue wrap; @@ -365,7 +365,7 @@ class IndexedEntity { } @Test - public void customBridge_implicitFieldType_invalid() { + void customBridge_implicitFieldType_invalid() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -392,7 +392,7 @@ class IndexedEntity { } @Test - public void customBridge_explicitFieldType_invalid() { + void customBridge_explicitFieldType_invalid() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -421,7 +421,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3243") - public void customBridge_implicitFieldType_generic() { + void customBridge_implicitFieldType_generic() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBindingBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBindingBaseIT.java index 90e8dafa8e2..a010c5e78da 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBindingBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBindingBaseIT.java @@ -27,27 +27,27 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of the {@link TypeBinding} annotation. */ @SuppressWarnings("unused") @TestForIssue(jiraKey = "HSEARCH-3135") -public class TypeBindingBaseIT { +class TypeBindingBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -55,7 +55,7 @@ public class TypeBindingBaseIT { * Basic test checking that a simple type binding will be applied as expected. */ @Test - public void simple() { + void simple() { backendMock.expectSchema( INDEX_NAME, b -> b.field( "myText", String.class ) ); @@ -89,7 +89,7 @@ public void bind(TypeBindingContext context) { } @Test - public void missingBinderReference() { + void missingBinderReference() { @Indexed @TypeBinding(binder = @TypeBinderRef) class IndexedEntity { @@ -108,7 +108,7 @@ class IndexedEntity { } @Test - public void customBridge_withParams_annotationMapping() { + void customBridge_withParams_annotationMapping() { backendMock.expectSchema( INDEX_NAME, b -> { b.field( "quotient", Integer.class ); b.field( "reminder", Integer.class ); @@ -135,7 +135,7 @@ public void customBridge_withParams_annotationMapping() { } @Test - public void customBridge_withParams_paramNotDefined() { + void customBridge_withParams_paramNotDefined() { assertThatThrownBy( () -> setupHelper.start().expectCustomBeans().setup( AnnotatedNoParamEntity.class ) ) @@ -147,7 +147,7 @@ public void customBridge_withParams_paramNotDefined() { } @Test - public void customBridge_withParams_paramDefinedTwice() { + void customBridge_withParams_paramDefinedTwice() { assertThatThrownBy( () -> setupHelper.start().expectCustomBeans().setup( AnnotatedSameParamTwiceEntity.class ) ) @@ -161,7 +161,7 @@ public void customBridge_withParams_paramDefinedTwice() { } @Test - public void customBridge_withParams_programmaticMapping() { + void customBridge_withParams_programmaticMapping() { backendMock.expectSchema( INDEX_NAME, b -> { b.field( "quotient", Integer.class ); b.field( "reminder", Integer.class ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBridgeBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBridgeBaseIT.java index cc78dfa7c1a..e19cc86969c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBridgeBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBridgeBaseIT.java @@ -15,7 +15,6 @@ import org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaObjectField; import org.hibernate.search.engine.backend.types.ObjectStructure; import org.hibernate.search.engine.search.predicate.definition.PredicateDefinition; -import org.hibernate.search.integrationtest.mapper.pojo.mapping.annotation.processing.CustomTypeMappingAnnotationBaseIT; import org.hibernate.search.mapper.pojo.bridge.TypeBridge; import org.hibernate.search.mapper.pojo.bridge.binding.TypeBindingContext; import org.hibernate.search.mapper.pojo.bridge.mapping.annotation.TypeBinderRef; @@ -31,30 +30,30 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.AssertionFailure; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test common use cases of (custom) type bridges. *

* Does not test reindexing in depth; this is tested in {@code AutomaticIndexing*} tests in the ORM mapper. *

- * Does not test custom annotations; this is tested in {@link CustomTypeMappingAnnotationBaseIT}. + * Does not test custom annotations; this is tested in {@code CustomTypeMappingAnnotationBaseIT}. */ @SuppressWarnings("unused") -public class TypeBridgeBaseIT { +class TypeBridgeBaseIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -66,7 +65,7 @@ public class TypeBridgeBaseIT { */ @Test @TestForIssue(jiraKey = { "HSEARCH-2055", "HSEARCH-2641" }) - public void accessors() { + void accessors() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -132,7 +131,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitDependencies() { + void explicitDependencies() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -189,7 +188,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitDependencies_error_invalidProperty() { + void explicitDependencies_error_invalidProperty() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -222,7 +221,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing() { + void explicitReindexing() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -294,7 +293,7 @@ class ContainedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_use_invalidProperty() { + void explicitReindexing_error_use_invalidProperty() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -333,7 +332,7 @@ class ContainedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_fromOtherEntity_invalidProperty() { + void explicitReindexing_error_fromOtherEntity_invalidProperty() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -367,7 +366,7 @@ class ContainedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_fromOtherEntity_bridgedElementNotEntityType() { + void explicitReindexing_error_fromOtherEntity_bridgedElementNotEntityType() { class NotEntity { String stringProperty; @@ -411,7 +410,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_fromOtherEntity_otherEntityTypeNotEntityType() { + void explicitReindexing_error_fromOtherEntity_otherEntityTypeNotEntityType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -446,7 +445,7 @@ class NotEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void explicitReindexing_error_fromOtherEntity_inverseAssociationPathTargetsWrongType() { + void explicitReindexing_error_fromOtherEntity_inverseAssociationPathTargetsWrongType() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -485,7 +484,7 @@ class ContainedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void missingDependencyDeclaration() { + void missingDependencyDeclaration() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -516,7 +515,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void inconsistentDependencyDeclaration() { + void inconsistentDependencyDeclaration() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -549,7 +548,7 @@ class IndexedEntity { @Test @TestForIssue(jiraKey = "HSEARCH-3297") - public void useRootOnly() { + void useRootOnly() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -633,7 +632,7 @@ private enum CustomEnum { */ @Test @TestForIssue(jiraKey = "HSEARCH-3324") - public void field() { + void field() { class Contained { } @Indexed(index = INDEX_NAME) @@ -676,7 +675,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3324") - public void objectField() { + void objectField() { class Contained { } @Indexed(index = INDEX_NAME) @@ -729,7 +728,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3273") - public void fieldTemplate() { + void fieldTemplate() { class Contained { } @Indexed(index = INDEX_NAME) @@ -777,7 +776,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-3273") - public void objectFieldTemplate() { + void objectFieldTemplate() { class Contained { } @Indexed(index = INDEX_NAME) @@ -834,7 +833,7 @@ class IndexedEntity { } @Test - public void accessors_incompatibleRequestedType() { + void accessors_incompatibleRequestedType() { @Indexed class IndexedEntity { @DocumentId @@ -867,7 +866,7 @@ public void write(DocumentElement target, Object bridgedElement, TypeBridgeWrite } @Test - public void typeBridge_invalidInputType() { + void typeBridge_invalidInputType() { @Indexed @TypeBinding(binder = @TypeBinderRef(type = MyTargetTypeBridge.Binder.class)) class IndexedEntity { @@ -913,7 +912,7 @@ public interface TargetType { * Test for backward compatibility with 6.0.0.CR1 APIs */ @Test - public void typeBridge_noGenericType() { + void typeBridge_noGenericType() { backendMock.expectSchema( INDEX_NAME, b -> b.field( "someField", String.class ) ); SearchMapping mapping = setupHelper.start().expectCustomBeans().setup( IndexedEntityWithRawTypeBridge.class ); backendMock.verifyExpectationsMet(); @@ -970,7 +969,7 @@ private static class IndexedEntityWithRawTypeBridge { */ @Test @TestForIssue(jiraKey = "HSEARCH-4166") - public void namedPredicate() { + void namedPredicate() { class Contained { } @Indexed(index = INDEX_NAME) @@ -1015,7 +1014,7 @@ class IndexedEntity { */ @Test @TestForIssue(jiraKey = "HSEARCH-4166") - public void namedPredicate_indexedEmbeddedIncludePaths() { + void namedPredicate_indexedEmbeddedIncludePaths() { class Contained { } @Indexed(index = INDEX_NAME) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBridgeRuntimePolymorphismHackIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBridgeRuntimePolymorphismHackIT.java index 88f490619bc..19798585a8d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBridgeRuntimePolymorphismHackIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/TypeBridgeRuntimePolymorphismHackIT.java @@ -28,30 +28,30 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * See https://discourse.hibernate.org/t/runtime-polymophism-with-typebinder-bridge/6057/2 */ @TestForIssue(jiraKey = "HSEARCH-4491") -public class TypeBridgeRuntimePolymorphismHackIT { +class TypeBridgeRuntimePolymorphismHackIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void explicitReindexing_hack_runtimePolymorphism() { + void explicitReindexing_hack_runtimePolymorphism() { backendMock.expectSchema( INDEX_NAME, b -> b.objectField( "contained", b2 -> b2 .field( "someField", String.class ) ) ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/AbstractMassIndexingErrorIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/AbstractMassIndexingErrorIT.java index a9806352f7a..906465bbc4a 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/AbstractMassIndexingErrorIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/AbstractMassIndexingErrorIT.java @@ -38,15 +38,15 @@ import org.hibernate.search.mapper.pojo.standalone.loading.MassLoadingStrategy; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.massindexing.MassIndexer; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.ThreadSpy; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.ThreadSpy; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubIndexScaleWork; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; import org.awaitility.Awaitility; @@ -60,21 +60,21 @@ public abstract class AbstractMassIndexingErrorIT { public static final String TITLE_3 = "Frankenstein"; public static final String AUTHOR_3 = "Mary Shelley"; - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public ThreadSpy threadSpy = new ThreadSpy(); + @RegisterExtension + public ThreadSpy threadSpy = ThreadSpy.create(); private final StubLoadingContext loadingContext = new StubLoadingContext(); @Test @TestForIssue(jiraKey = { "HSEARCH-4218", "HSEARCH-4236" }) - public void identifierLoading() { + void identifierLoading() { String errorMessage = "ID loading error"; SearchMapping mapping = setupWithThrowingIdentifierLoading( errorMessage ); @@ -95,7 +95,7 @@ public void identifierLoading() { @Test @TestForIssue(jiraKey = "HSEARCH-4236") - public void entityLoading() { + void entityLoading() { String errorMessage = "entity loading error"; SearchMapping mapping = setupWithThrowingEntityLoading( errorMessage ); @@ -117,7 +117,7 @@ public void entityLoading() { } @Test - public void indexing() { + void indexing() { SearchMapping mapping = setup(); String errorMessage = "Indexing error"; @@ -138,7 +138,7 @@ public void indexing() { } @Test - public void getId() { + void getId() { SearchMapping mapping = setup(); String errorMessage = "getId error"; @@ -161,7 +161,7 @@ public void getId() { } @Test - public void getTitle() { + void getTitle() { SearchMapping mapping = setup(); String errorMessage = "getTitle error"; @@ -183,7 +183,7 @@ public void getTitle() { } @Test - public void dropAndCreateSchema_exception() { + void dropAndCreateSchema_exception() { SearchMapping mapping = setup(); String errorMessage = "DROP_AND_CREATE error"; @@ -202,7 +202,7 @@ public void dropAndCreateSchema_exception() { } @Test - public void purge() { + void purge() { SearchMapping mapping = setup(); String errorMessage = "PURGE error"; @@ -221,7 +221,7 @@ public void purge() { } @Test - public void mergeSegmentsBefore() { + void mergeSegmentsBefore() { SearchMapping mapping = setup(); String errorMessage = "MERGE_SEGMENTS error"; @@ -241,7 +241,7 @@ public void mergeSegmentsBefore() { } @Test - public void mergeSegmentsAfter() { + void mergeSegmentsAfter() { SearchMapping mapping = setup(); String errorMessage = "MERGE_SEGMENTS error"; @@ -264,7 +264,7 @@ public void mergeSegmentsAfter() { } @Test - public void flush() { + void flush() { SearchMapping mapping = setup(); String errorMessage = "FLUSH error"; @@ -286,7 +286,7 @@ public void flush() { } @Test - public void refresh() { + void refresh() { SearchMapping mapping = setup(); String errorMessage = "REFRESH error"; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/AbstractMassIndexingFailureIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/AbstractMassIndexingFailureIT.java index 2122ecb5711..454c6309e67 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/AbstractMassIndexingFailureIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/AbstractMassIndexingFailureIT.java @@ -42,16 +42,16 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.massindexing.MassIndexer; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.ThreadSpy; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.ThreadSpy; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubIndexScaleWork; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; import org.awaitility.Awaitility; @@ -68,15 +68,15 @@ public abstract class AbstractMassIndexingFailureIT { public static final String TITLE_3 = "Frankenstein"; public static final String AUTHOR_3 = "Mary Shelley"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public ThreadSpy threadSpy = new ThreadSpy(); + @RegisterExtension + public ThreadSpy threadSpy = ThreadSpy.create(); private final StubLoadingContext loadingContext = new StubLoadingContext(); @@ -86,7 +86,7 @@ public int getDefaultFailureFloodingThreshold() { @Test @TestForIssue(jiraKey = { "HSEARCH-4218", "HSEARCH-4236" }) - public void identifierLoading() { + void identifierLoading() { String exceptionMessage = "ID loading error"; SearchMapping mapping = setupWithThrowingIdentifierLoading( exceptionMessage ); @@ -119,13 +119,13 @@ public void identifierLoading() { @Test @TestForIssue(jiraKey = "HSEARCH-4236") - public void entityLoading() { + void entityLoading() { entityLoading( Optional.empty() ); } @Test @TestForIssue(jiraKey = "HSEARCH-4236") - public void entityLoadingWithFailureFloodingThreshold() { + void entityLoadingWithFailureFloodingThreshold() { entityLoading( Optional.of( FAILURE_FLOODING_THRESHOLD ) ); } @@ -186,7 +186,7 @@ public void entityLoading(Optional failureFloodingThreshold) { } @Test - public void indexing() { + void indexing() { SearchMapping mapping = setup(); String entityName = Book.NAME; @@ -224,7 +224,7 @@ public void indexing() { } @Test - public void getId() { + void getId() { SearchMapping mapping = setup(); String entityName = Book.NAME; @@ -265,7 +265,7 @@ public void getId() { } @Test - public void getTitle() { + void getTitle() { SearchMapping mapping = setup(); String entityName = Book.NAME; @@ -306,7 +306,7 @@ public void getTitle() { } @Test - public void dropAndCreateSchema_exception() { + void dropAndCreateSchema_exception() { SearchMapping mapping = setup(); String exceptionMessage = "DROP_AND_CREATE failure"; @@ -329,7 +329,7 @@ public void dropAndCreateSchema_exception() { } @Test - public void purge() { + void purge() { SearchMapping mapping = setup(); String exceptionMessage = "PURGE failure"; @@ -355,7 +355,7 @@ public void purge() { } @Test - public void mergeSegmentsBefore() { + void mergeSegmentsBefore() { SearchMapping mapping = setup(); String exceptionMessage = "MERGE_SEGMENTS failure"; @@ -382,7 +382,7 @@ public void mergeSegmentsBefore() { } @Test - public void mergeSegmentsAfter() { + void mergeSegmentsAfter() { SearchMapping mapping = setup(); String exceptionMessage = "MERGE_SEGMENTS failure"; @@ -412,7 +412,7 @@ public void mergeSegmentsAfter() { } @Test - public void flush() { + void flush() { SearchMapping mapping = setup(); String exceptionMessage = "FLUSH failure"; @@ -441,7 +441,7 @@ public void flush() { } @Test - public void refresh() { + void refresh() { SearchMapping mapping = setup(); String exceptionMessage = "REFRESH failure"; @@ -471,7 +471,7 @@ public void refresh() { } @Test - public void indexingAndFlush() { + void indexingAndFlush() { SearchMapping mapping = setup(); String entityName = Book.NAME; @@ -519,7 +519,7 @@ public void indexingAndFlush() { } @Test - public void indexingAndRefresh() { + void indexingAndRefresh() { SearchMapping mapping = setup(); String entityName = Book.NAME; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingBaseIT.java index ff7e376e0e1..8337d463ef8 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingBaseIT.java @@ -23,18 +23,18 @@ import org.hibernate.search.mapper.pojo.standalone.massindexing.MassIndexer; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Very basic test to probe an use of {@link MassIndexer} api. */ -public class MassIndexingBaseIT { +class MassIndexingBaseIT { public static final String TITLE_1 = "Oliver Twist"; public static final String AUTHOR_1 = "Charles Dickens"; @@ -43,10 +43,10 @@ public class MassIndexingBaseIT { public static final String TITLE_3 = "Frankenstein"; public static final String AUTHOR_3 = "Mary Shelley"; - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -54,8 +54,8 @@ public class MassIndexingBaseIT { private final StubLoadingContext loadingContext = new StubLoadingContext(); - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Book.INDEX ); mapping = setupHelper.start() @@ -71,7 +71,7 @@ public void setup() { } @Test - public void defaultMassIndexerStartAndWait() throws Exception { + void defaultMassIndexerStartAndWait() throws Exception { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer() // Simulate passing information to connect to a DB, ... @@ -116,7 +116,7 @@ public void defaultMassIndexerStartAndWait() throws Exception { } @Test - public void dropAndCreateSchemaOnStart() { + void dropAndCreateSchemaOnStart() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer() // Simulate passing information to connect to a DB, ... @@ -163,7 +163,7 @@ public void dropAndCreateSchemaOnStart() { } @Test - public void mergeSegmentsOnFinish() { + void mergeSegmentsOnFinish() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer() // Simulate passing information to connect to a DB, ... @@ -211,7 +211,7 @@ public void mergeSegmentsOnFinish() { } @Test - public void dropAndCreateSchemaOnStartAndPurgeBothEnabled() { + void dropAndCreateSchemaOnStartAndPurgeBothEnabled() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer() // Simulate passing information to connect to a DB, ... @@ -261,7 +261,7 @@ public void dropAndCreateSchemaOnStartAndPurgeBothEnabled() { } @Test - public void fromMappingWithoutSession() { + void fromMappingWithoutSession() { MassIndexer indexer = mapping.scope( Object.class ).massIndexer() // Simulate passing information to connect to a DB, ... .context( StubLoadingContext.class, loadingContext ); @@ -303,7 +303,7 @@ public void fromMappingWithoutSession() { } @Test - public void reuseSearchSessionAfterSearchSessionIsClosed_createMassIndexer() { + void reuseSearchSessionAfterSearchSessionIsClosed_createMassIndexer() { SearchSession searchSession = mapping.createSession(); // a SearchSession instance is created lazily, // so we need to use it to have an instance of it @@ -318,7 +318,7 @@ public void reuseSearchSessionAfterSearchSessionIsClosed_createMassIndexer() { } @Test - public void lazyCreateSearchSessionAfterSearchSessionIsClosed_createMassIndexer() { + void lazyCreateSearchSessionAfterSearchSessionIsClosed_createMassIndexer() { // Search session is not created, since we don't use it SearchSession searchSession = mapping.createSession(); searchSession.close(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingComplexHierarchyIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingComplexHierarchyIT.java index 3818045dbc8..d8c724d5776 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingComplexHierarchyIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingComplexHierarchyIT.java @@ -22,23 +22,23 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.massindexing.MassIndexer; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test that the {@link MassIndexer} correctly indexes even complex entity hierarchies * where superclasses are indexed but not all of their subclasses, and vice-versa. */ -public class MassIndexingComplexHierarchyIT { +class MassIndexingComplexHierarchyIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -46,8 +46,8 @@ public class MassIndexingComplexHierarchyIT { private final StubLoadingContext loadingContext = new StubLoadingContext(); - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( H1_B_Indexed.NAME ); backendMock.expectAnySchema( H2_Root_Indexed.NAME ); backendMock.expectAnySchema( H2_A_C_Indexed.NAME ); @@ -82,7 +82,7 @@ public void setup() { } @Test - public void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { + void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer( H1_Root_NotIndexed.class ) // Simulate passing information to connect to a DB, ... @@ -110,7 +110,7 @@ public void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { } @Test - public void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSubclass() { + void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSubclass() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer( H1_B_Indexed.class ) // Simulate passing information to connect to a DB, ... @@ -138,7 +138,7 @@ public void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSub } @Test - public void rootIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { + void rootIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer( H2_Root_Indexed.class ) // Simulate passing information to connect to a DB, ... @@ -182,7 +182,7 @@ public void rootIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { } @Test - public void rootIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSubclass() { + void rootIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSubclass() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer( H2_B_Indexed.class ) // Simulate passing information to connect to a DB, ... diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingEnvironmentIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingEnvironmentIT.java index beb83572822..d12aee489c6 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingEnvironmentIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingEnvironmentIT.java @@ -28,19 +28,19 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.Futures; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MassIndexingEnvironmentIT { +class MassIndexingEnvironmentIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -48,8 +48,8 @@ public class MassIndexingEnvironmentIT { private final StubLoadingContext loadingContext = new StubLoadingContext(); - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Entity.INDEX ); mapping = setupHelper.start() @@ -65,7 +65,7 @@ public void setup() { } @Test - public void success() throws InterruptedException { + void success() throws InterruptedException { try ( SearchSession searchSession = mapping.createSession() ) { Queue before = new ArrayBlockingQueue<>( 10 ); Queue after = new ArrayBlockingQueue<>( 10 ); @@ -118,7 +118,7 @@ public void afterExecution(Context context) { } @Test - public void testFailingEntityLoading() { + void testFailingEntityLoading() { testFailingBeforeHook( MassIndexingEnvironment.EntityLoadingContext.class, "don't call me in entity loading." @@ -126,7 +126,7 @@ public void testFailingEntityLoading() { } @Test - public void testFailingEntityIdentifierLoading() { + void testFailingEntityIdentifierLoading() { testFailingBeforeHook( MassIndexingEnvironment.EntityIdentifierLoadingContext.class, "don't call me in identifier loading." diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorCustomBackgroundFailureHandlerIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorCustomBackgroundFailureHandlerIT.java index 4105a345fc7..786565bafc8 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorCustomBackgroundFailureHandlerIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorCustomBackgroundFailureHandlerIT.java @@ -12,17 +12,16 @@ import org.hibernate.search.engine.reporting.FailureHandler; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; -import org.junit.Rule; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class MassIndexingErrorCustomBackgroundFailureHandlerIT extends AbstractMassIndexingErrorIT { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class MassIndexingErrorCustomBackgroundFailureHandlerIT extends AbstractMassIndexingErrorIT { @Mock private FailureHandler failureHandler; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorCustomMassIndexingFailureHandlerIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorCustomMassIndexingFailureHandlerIT.java index 65dd7e0a916..70d9579d6e0 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorCustomMassIndexingFailureHandlerIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorCustomMassIndexingFailureHandlerIT.java @@ -12,17 +12,16 @@ import org.hibernate.search.engine.reporting.FailureHandler; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; -import org.junit.Rule; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class MassIndexingErrorCustomMassIndexingFailureHandlerIT extends AbstractMassIndexingErrorIT { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class MassIndexingErrorCustomMassIndexingFailureHandlerIT extends AbstractMassIndexingErrorIT { @Mock private MassIndexingFailureHandler failureHandler; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorDefaultBackgroundFailureHandlerIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorDefaultBackgroundFailureHandlerIT.java index 5262f4ad322..62ff40bd974 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorDefaultBackgroundFailureHandlerIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingErrorDefaultBackgroundFailureHandlerIT.java @@ -8,15 +8,15 @@ import org.hibernate.search.engine.reporting.FailureHandler; import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; -public class MassIndexingErrorDefaultBackgroundFailureHandlerIT extends AbstractMassIndexingErrorIT { +class MassIndexingErrorDefaultBackgroundFailureHandlerIT extends AbstractMassIndexingErrorIT { - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Override diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureCustomBackgroundFailureHandlerIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureCustomBackgroundFailureHandlerIT.java index e4ace0c1f31..79f66d25a3d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureCustomBackgroundFailureHandlerIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureCustomBackgroundFailureHandlerIT.java @@ -22,23 +22,23 @@ import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.assertj.core.api.InstanceOfAssertFactories; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class MassIndexingFailureCustomBackgroundFailureHandlerIT extends AbstractMassIndexingFailureIT { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class MassIndexingFailureCustomBackgroundFailureHandlerIT extends AbstractMassIndexingFailureIT { private static final int DEFAULT_FAILURE_FLOODING_THRESHOLD = 100; - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); @Mock private FailureHandler failureHandler; @@ -215,8 +215,8 @@ protected void assertEntityIndexingAndMassIndexerOperationFailureHandling(String .isEqualTo( failingMassIndexerOperationAsString ); } - @Before - public void setUp() { + @BeforeEach + void setUp() { lenient().when( failureHandler.failureFloodingThreshold() ).thenReturn( (long) getDefaultFailureFloodingThreshold() ); } diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureCustomMassIndexingFailureHandlerIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureCustomMassIndexingFailureHandlerIT.java index 89438cadf8f..d57bc8a72ac 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureCustomMassIndexingFailureHandlerIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureCustomMassIndexingFailureHandlerIT.java @@ -22,24 +22,23 @@ import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.assertj.core.api.InstanceOfAssertFactories; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class MassIndexingFailureCustomMassIndexingFailureHandlerIT extends AbstractMassIndexingFailureIT { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class MassIndexingFailureCustomMassIndexingFailureHandlerIT extends AbstractMassIndexingFailureIT { private static final int DEFAULT_FAILURE_FLOODING_THRESHOLD = 62; - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private MassIndexingFailureHandler failureHandler; @@ -216,8 +215,8 @@ protected void assertEntityIndexingAndMassIndexerOperationFailureHandling(String .isEqualTo( failingMassIndexerOperationAsString ); } - @Before - public void setUp() { + @BeforeEach + void setUp() { lenient().when( failureHandler.failureFloodingThreshold() ).thenReturn( (long) getDefaultFailureFloodingThreshold() ); } diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureDefaultBackgroundFailureHandlerIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureDefaultBackgroundFailureHandlerIT.java index 49f6808cd14..5c6cbf332fe 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureDefaultBackgroundFailureHandlerIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingFailureDefaultBackgroundFailureHandlerIT.java @@ -11,15 +11,15 @@ import org.hibernate.search.mapper.pojo.massindexing.MassIndexingFailureHandler; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.test.ExceptionMatcherBuilder; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; -public class MassIndexingFailureDefaultBackgroundFailureHandlerIT extends AbstractMassIndexingFailureIT { +class MassIndexingFailureDefaultBackgroundFailureHandlerIT extends AbstractMassIndexingFailureIT { - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Override diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingIncludedEntityMapHierarchyIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingIncludedEntityMapHierarchyIT.java index fbb876c16ee..cd7e9e950b5 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingIncludedEntityMapHierarchyIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingIncludedEntityMapHierarchyIT.java @@ -25,16 +25,17 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.massindexing.MassIndexer; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; /** @@ -43,22 +44,21 @@ * It also tests {@link LoadingTypeGroup#includedTypesMap()}, * and the position of the first item for the group super type. */ -public class MassIndexingIncludedEntityMapHierarchyIT { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class MassIndexingIncludedEntityMapHierarchyIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( H1_B_Indexed.NAME ); backendMock.expectAnySchema( H2_Root_Indexed.NAME ); backendMock.expectAnySchema( H2_A_C_Indexed.NAME ); @@ -82,7 +82,7 @@ public void setup() { } @Test - public void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { + void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer( H1_Root_NotIndexed.class ); @@ -107,7 +107,7 @@ public void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { } @Test - public void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSubclass() { + void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSubclass() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer( H1_B_Indexed.class ); @@ -132,7 +132,7 @@ public void rootNotIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSub } @Test - public void rootIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { + void rootIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer( H2_Root_Indexed.class ); @@ -166,7 +166,7 @@ public void rootIndexed_someSubclassesIndexed_requestMassIndexingOnRoot() { } @Test - public void rootIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSubclass() { + void rootIndexed_someSubclassesIndexed_requestMassIndexingOnIndexedSubclass() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer( H2_B_Indexed.class ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingInterruptionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingInterruptionIT.java index b3a10ed4e0e..d2a24252efc 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingInterruptionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingInterruptionIT.java @@ -26,13 +26,13 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.massindexing.MassIndexer; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.ThreadSpy; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.ThreadSpy; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.InstanceOfAssertFactories; import org.awaitility.Awaitility; @@ -40,27 +40,27 @@ /** * Test interruption of a currently executing {@link MassIndexer}. */ -public class MassIndexingInterruptionIT { +class MassIndexingInterruptionIT { public static final String TITLE_1 = "Oliver Twist"; public static final String AUTHOR_1 = "Charles Dickens"; - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public ThreadSpy threadSpy = new ThreadSpy(); + @RegisterExtension + public ThreadSpy threadSpy = ThreadSpy.create(); private SearchMapping mapping; private final StubLoadingContext loadingContext = new StubLoadingContext(); - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Book.INDEX ); mapping = setupHelper.start() @@ -77,7 +77,7 @@ public void setup() { } @Test - public void interrupt_mainThread() { + void interrupt_mainThread() { int expectedThreadCount = 1 // Workspace + 1 // ID loading + 1; // Entity loading @@ -122,7 +122,7 @@ public void interrupt_mainThread() { } @Test - public void interrupt_entityLoading() { + void interrupt_entityLoading() { int expectedThreadCount = 1 // Workspace + 1 // ID loading + 1; // Entity loading @@ -163,7 +163,7 @@ public void interrupt_entityLoading() { } @Test - public void cancel() { + void cancel() { int expectedThreadCount = 1 // Coordinator + 1 // Workspace + 1 // ID loading diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingMonitorIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingMonitorIT.java index 7b0f1f3cf7a..a3e788c9142 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingMonitorIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingMonitorIT.java @@ -26,14 +26,14 @@ import org.hibernate.search.mapper.pojo.standalone.massindexing.MassIndexer; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class MassIndexingMonitorIT { +class MassIndexingMonitorIT { public static final String TITLE_1 = "Oliver Twist"; public static final String AUTHOR_1 = "Charles Dickens"; @@ -42,14 +42,14 @@ public class MassIndexingMonitorIT { public static final String TITLE_3 = "Frankenstein"; public static final String AUTHOR_3 = "Mary Shelley"; - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public StaticCounters staticCounters = new StaticCounters(); + @RegisterExtension + public StaticCounters staticCounters = StaticCounters.create(); private final StubLoadingContext loadingContext = new StubLoadingContext(); @@ -72,7 +72,7 @@ private SearchMapping setup(String failureHandler) { } @Test - public void simple() { + void simple() { SearchMapping mapping = setup( null ); try ( SearchSession searchSession = mapping.createSession() ) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingPrimitiveIdIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingPrimitiveIdIT.java index a005bcd783b..f1dd970f231 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingPrimitiveIdIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/massindexing/MassIndexingPrimitiveIdIT.java @@ -20,21 +20,21 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.massindexing.MassIndexer; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-3529") -public class MassIndexingPrimitiveIdIT { +class MassIndexingPrimitiveIdIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @@ -42,8 +42,8 @@ public class MassIndexingPrimitiveIdIT { private final StubLoadingContext loadingContext = new StubLoadingContext(); - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( EntityWithPrimitiveId.INDEX ); mapping = setupHelper.start() @@ -59,7 +59,7 @@ public void setup() { } @Test - public void entityWithPrimitiveId() { + void entityWithPrimitiveId() { try ( SearchSession searchSession = mapping.createSession() ) { MassIndexer indexer = searchSession.massIndexer() // Simulate passing information to connect to a DB, ... diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/AbstractInterfaceIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/AbstractInterfaceIT.java index ffc8b8841e7..65ba4948e41 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/AbstractInterfaceIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/AbstractInterfaceIT.java @@ -14,13 +14,13 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test that annotations on interfaces are correctly detected @@ -28,19 +28,19 @@ * i.e. when no implementation is known by HSearch. */ @TestForIssue(jiraKey = "HSEARCH-4385") -public class AbstractInterfaceIT { +class AbstractInterfaceIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.class.getSimpleName(), b -> b .objectField( "embedded", b2 -> b2 .field( "text", String.class ) ) @@ -51,7 +51,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity = new IndexedEntity( 1, new AbstractInterface() { @Override diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/AnnotationMappingAccessTypeIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/AnnotationMappingAccessTypeIT.java index 89e546135a8..989ebf6395a 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/AnnotationMappingAccessTypeIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/AnnotationMappingAccessTypeIT.java @@ -13,12 +13,12 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Integration tests checking that we get the expected access type for properties when using annotation mapping, @@ -26,19 +26,19 @@ *

* Similar to {@link ProgrammaticMappingAccessTypeIT}, which tests programmatic mapping. */ -public class AnnotationMappingAccessTypeIT { +class AnnotationMappingAccessTypeIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.NAME, b -> b .field( "propertyWithGetterAndFieldDeclaredInParent", String.class ) .field( "propertyWithFieldDeclaredInParent", String.class ) @@ -59,7 +59,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity(); entity1.id = 1; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/DuplicateGetterIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/DuplicateGetterIT.java index 5d09f8ebf54..0100bd0b74c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/DuplicateGetterIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/DuplicateGetterIT.java @@ -13,13 +13,13 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.apache.logging.log4j.Level; @@ -27,20 +27,20 @@ * Test models with multiple getters for the same property. */ @TestForIssue(jiraKey = "HSEARCH-4117") -public class DuplicateGetterIT { +class DuplicateGetterIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); @Test - public void duplicateGetter_unmapped() { + void duplicateGetter_unmapped() { final String indexName = "indexName"; @Indexed(index = indexName) class IndexedEntity { @@ -69,7 +69,7 @@ public Boolean getEnabled() { } @Test - public void duplicateGetter_mapped() { + void duplicateGetter_mapped() { final String indexName = "indexName"; @Indexed(index = indexName) class IndexedEntity { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/GenericPropertyIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/GenericPropertyIT.java index 057f96671aa..0ca59457bd6 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/GenericPropertyIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/GenericPropertyIT.java @@ -17,26 +17,26 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class GenericPropertyIT { +class GenericPropertyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "genericProperty", b2 -> b2 /* @@ -55,7 +55,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity(); entity1.id = 1; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/ImplementedInterfaceIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/ImplementedInterfaceIT.java index b2c2f1b225d..d09ea21ab19 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/ImplementedInterfaceIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/ImplementedInterfaceIT.java @@ -13,28 +13,28 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; @TestForIssue(jiraKey = "HSEARCH-1656") -public class ImplementedInterfaceIT { +class ImplementedInterfaceIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedPojo.class.getSimpleName(), b -> b .field( "text", String.class ) ); @@ -44,7 +44,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { IndexedPojo indexedPojo = new IndexedPojo( 1, "Using some other text here" ); session.indexingPlan().add( indexedPojo ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/ProgrammaticMappingAccessTypeIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/ProgrammaticMappingAccessTypeIT.java index 465c65fa04f..68ccc387c1d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/ProgrammaticMappingAccessTypeIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/ProgrammaticMappingAccessTypeIT.java @@ -12,12 +12,12 @@ import org.hibernate.search.mapper.pojo.mapping.definition.programmatic.TypeMappingStep; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Integration tests checking that we get the expected access type for properties when using programmatic mapping, @@ -25,19 +25,19 @@ *

* Similar to {@link AnnotationMappingAccessTypeIT}, which tests annotation mapping. */ -public class ProgrammaticMappingAccessTypeIT { +class ProgrammaticMappingAccessTypeIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.NAME, b -> b .field( "propertyWithGetterAndFieldDeclaredInParent", String.class ) .field( "propertyWithFieldDeclaredInParent", String.class ) @@ -73,7 +73,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity(); entity1.id = 1; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/PropertyInheritanceIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/PropertyInheritanceIT.java index 7c085cfde22..03a90662bd7 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/PropertyInheritanceIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/model/PropertyInheritanceIT.java @@ -17,26 +17,26 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class PropertyInheritanceIT { +class PropertyInheritanceIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "parentDeclaredProperty", String.class ) .field( "childDeclaredProperty", String.class ) @@ -54,7 +54,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity(); entity1.setId( 1 ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/providedid/ProvidedIdIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/providedid/ProvidedIdIT.java index de828526647..4f4227ecf8a 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/providedid/ProvidedIdIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/providedid/ProvidedIdIT.java @@ -31,28 +31,28 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendUtils; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.model.impl.StubIndexModel; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProvidedIdIT { +class ProvidedIdIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private StubIndexModel indexModel; @Test - public void converters() { + void converters() { final String entityAndIndexName = "indexed"; @Indexed class IndexedEntity { @@ -90,7 +90,7 @@ class IndexedEntity { } @Test - public void indexAndSearch() { + void indexAndSearch() { final String entityAndIndexName = "indexed"; @Indexed class IndexedEntity { @@ -147,7 +147,7 @@ class IndexedEntity { } @Test - public void error_nullProvidedId() { + void error_nullProvidedId() { final String entityAndIndexName = "indexed"; @Indexed class IndexedEntity { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/AbstractSearchSchemaManagerSimpleOperationIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/AbstractSearchSchemaManagerSimpleOperationIT.java index 5eab04271b1..baca20c745a 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/AbstractSearchSchemaManagerSimpleOperationIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/AbstractSearchSchemaManagerSimpleOperationIT.java @@ -17,28 +17,28 @@ import org.hibernate.search.mapper.pojo.standalone.schema.management.SearchSchemaManager; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; public abstract class AbstractSearchSchemaManagerSimpleOperationIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); protected SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( IndexedEntity1.NAME ); backendMock.expectAnySchema( IndexedEntity2.NAME ); @@ -49,7 +49,7 @@ public void setup() { } @Test - public void success_fromMapping_single() { + void success_fromMapping_single() { try ( SearchSession searchSession = mapping.createSession() ) { SearchSchemaManager manager = searchSession .scope( IndexedEntity1.class ) @@ -61,7 +61,7 @@ public void success_fromMapping_single() { } @Test - public void success_fromMapping_all() { + void success_fromMapping_all() { try ( SearchSession searchSession = mapping.createSession() ) { SearchSchemaManager manager = searchSession .scope( Object.class ) @@ -74,7 +74,7 @@ public void success_fromMapping_all() { } @Test - public void success_fromSession_single() { + void success_fromSession_single() { try ( SearchSession searchSession = mapping.createSession() ) { SearchSchemaManager manager = searchSession .schemaManager( IndexedEntity1.class ); @@ -85,7 +85,7 @@ public void success_fromSession_single() { } @Test - public void success_fromSession_all() { + void success_fromSession_all() { try ( SearchSession searchSession = mapping.createSession() ) { SearchSchemaManager manager = searchSession .schemaManager(); @@ -97,7 +97,7 @@ public void success_fromSession_all() { } @Test - public void exception_single() { + void exception_single() { try ( SearchSession searchSession = mapping.createSession() ) { SearchSchemaManager manager = searchSession .scope( Object.class ) @@ -116,7 +116,7 @@ public void exception_single() { } @Test - public void exception_multiple() { + void exception_multiple() { try ( SearchSession searchSession = mapping.createSession() ) { SearchSchemaManager manager = searchSession .scope( Object.class ) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/AbstractSearchSchemaManagerValidatingSimpleOperationIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/AbstractSearchSchemaManagerValidatingSimpleOperationIT.java index dc3c2bb460d..633f0da9a39 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/AbstractSearchSchemaManagerValidatingSimpleOperationIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/AbstractSearchSchemaManagerValidatingSimpleOperationIT.java @@ -15,13 +15,13 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class AbstractSearchSchemaManagerValidatingSimpleOperationIT extends AbstractSearchSchemaManagerSimpleOperationIT { @Test - public void failure_single() { + void failure_single() { try ( SearchSession searchSession = mapping.createSession() ) { SearchSchemaManager manager = searchSession .scope( Object.class ) @@ -42,7 +42,7 @@ public void failure_single() { } @Test - public void failure_multiple() { + void failure_multiple() { try ( SearchSession searchSession = mapping.createSession() ) { SearchSchemaManager manager = searchSession .scope( Object.class ) @@ -68,7 +68,7 @@ public void failure_multiple() { } @Test - public void failure_exception() { + void failure_exception() { try ( SearchSession searchSession = mapping.createSession() ) { SearchSchemaManager manager = searchSession .scope( Object.class ) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateIfMissingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateIfMissingIT.java index 018ea27911e..fbca7643fc9 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateIfMissingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateIfMissingIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.manager; import org.hibernate.search.mapper.pojo.standalone.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SearchSchemaManagerCreateIfMissingIT extends AbstractSearchSchemaManagerSimpleOperationIT { +class SearchSchemaManagerCreateIfMissingIT extends AbstractSearchSchemaManagerSimpleOperationIT { @Override protected void execute(SearchSchemaManager manager) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateOrUpdateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateOrUpdateIT.java index bccaa321bc1..2e21a7015a6 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateOrUpdateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateOrUpdateIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.manager; import org.hibernate.search.mapper.pojo.standalone.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SearchSchemaManagerCreateOrUpdateIT extends AbstractSearchSchemaManagerSimpleOperationIT { +class SearchSchemaManagerCreateOrUpdateIT extends AbstractSearchSchemaManagerSimpleOperationIT { @Override protected void execute(SearchSchemaManager manager) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateOrValidateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateOrValidateIT.java index ad3c85e1267..5eab7e03e59 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateOrValidateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerCreateOrValidateIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.manager; import org.hibernate.search.mapper.pojo.standalone.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SearchSchemaManagerCreateOrValidateIT extends AbstractSearchSchemaManagerValidatingSimpleOperationIT { +class SearchSchemaManagerCreateOrValidateIT extends AbstractSearchSchemaManagerValidatingSimpleOperationIT { @Override protected void execute(SearchSchemaManager manager) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerDropAndCreateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerDropAndCreateIT.java index e90deaacda5..527be3b7420 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerDropAndCreateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerDropAndCreateIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.manager; import org.hibernate.search.mapper.pojo.standalone.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SearchSchemaManagerDropAndCreateIT extends AbstractSearchSchemaManagerSimpleOperationIT { +class SearchSchemaManagerDropAndCreateIT extends AbstractSearchSchemaManagerSimpleOperationIT { @Override protected void execute(SearchSchemaManager manager) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerDropIfExistingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerDropIfExistingIT.java index bcae53741cc..a98345b0ef9 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerDropIfExistingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerDropIfExistingIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.manager; import org.hibernate.search.mapper.pojo.standalone.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SearchSchemaManagerDropIfExistingIT extends AbstractSearchSchemaManagerSimpleOperationIT { +class SearchSchemaManagerDropIfExistingIT extends AbstractSearchSchemaManagerSimpleOperationIT { @Override protected void execute(SearchSchemaManager manager) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerValidateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerValidateIT.java index 5d4dfd300f9..93e36b118ad 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerValidateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/manager/SearchSchemaManagerValidateIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.manager; import org.hibernate.search.mapper.pojo.standalone.schema.management.SearchSchemaManager; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SearchSchemaManagerValidateIT extends AbstractSearchSchemaManagerValidatingSimpleOperationIT { +class SearchSchemaManagerValidateIT extends AbstractSearchSchemaManagerValidatingSimpleOperationIT { @Override protected void execute(SearchSchemaManager manager) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/AbstractSchemaManagementStrategyIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/AbstractSchemaManagementStrategyIT.java index 677e2f86012..e63bc76e4b0 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/AbstractSchemaManagementStrategyIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/AbstractSchemaManagementStrategyIT.java @@ -17,25 +17,25 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.CloseableSearchMapping; import org.hibernate.search.mapper.pojo.standalone.schema.management.SchemaManagementStrategyName; import org.hibernate.search.util.common.SearchException; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; public abstract class AbstractSchemaManagementStrategyIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void noIndexedType() { + void noIndexedType() { SchemaManagementStrategyName strategyName = getStrategyName(); CloseableSearchMapping mapper = setupHelper.start() .withProperty( StandalonePojoMapperSettings.SCHEMA_MANAGEMENT_STRATEGY, @@ -51,7 +51,7 @@ public void noIndexedType() { } @Test - public void success() { + void success() { expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); expectWork( IndexedEntity2.NAME, CompletableFuture.completedFuture( null ) ); @@ -67,7 +67,7 @@ public void success() { } @Test - public void exception_single() { + void exception_single() { RuntimeException exception = new RuntimeException( "My exception" ); expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); @@ -81,7 +81,7 @@ public void exception_single() { } @Test - public void exception_multiple() { + void exception_multiple() { RuntimeException exception1 = new RuntimeException( "My exception 1" ); RuntimeException exception2 = new RuntimeException( "My exception 2" ); expectWork( IndexedEntity1.NAME, exceptionFuture( exception1 ) ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/AbstractSchemaManagementStrategyValidatingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/AbstractSchemaManagementStrategyValidatingIT.java index 3d06e0b4ad0..c011e76d799 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/AbstractSchemaManagementStrategyValidatingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/AbstractSchemaManagementStrategyValidatingIT.java @@ -13,12 +13,12 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; public abstract class AbstractSchemaManagementStrategyValidatingIT extends AbstractSchemaManagementStrategyIT { @Test - public void failure_single() { + void failure_single() { expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); expectWork( IndexedEntity2.NAME, failureCollector -> { failureCollector.add( "My failure" ); @@ -33,7 +33,7 @@ public void failure_single() { } @Test - public void failure_multiple() { + void failure_multiple() { expectWork( IndexedEntity1.NAME, failureCollector -> { failureCollector.add( "My failure 1" ); return CompletableFuture.completedFuture( null ); @@ -53,7 +53,7 @@ public void failure_multiple() { } @Test - public void failure_exception() { + void failure_exception() { RuntimeException exception = new RuntimeException( "My exception" ); expectWork( IndexedEntity1.NAME, failureCollector -> { failureCollector.add( "My failure" ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateIT.java index f1dcb73c03f..f6dace5da7d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.strategy; import org.hibernate.search.mapper.pojo.standalone.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SchemaManagementStrategyCreateIT extends AbstractSchemaManagementStrategyIT { +class SchemaManagementStrategyCreateIT extends AbstractSchemaManagementStrategyIT { @Override protected SchemaManagementStrategyName getStrategyName() { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateOrUpdateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateOrUpdateIT.java index 76f8d268347..c8ef14833fe 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateOrUpdateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateOrUpdateIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.strategy; import org.hibernate.search.mapper.pojo.standalone.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SchemaManagementStrategyCreateOrUpdateIT extends AbstractSchemaManagementStrategyIT { +class SchemaManagementStrategyCreateOrUpdateIT extends AbstractSchemaManagementStrategyIT { @Override protected SchemaManagementStrategyName getStrategyName() { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateOrValidateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateOrValidateIT.java index 66f0b3ad883..c514ad7c692 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateOrValidateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyCreateOrValidateIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.strategy; import org.hibernate.search.mapper.pojo.standalone.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SchemaManagementStrategyCreateOrValidateIT extends AbstractSchemaManagementStrategyValidatingIT { +class SchemaManagementStrategyCreateOrValidateIT extends AbstractSchemaManagementStrategyValidatingIT { @Override protected SchemaManagementStrategyName getStrategyName() { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDefaultIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDefaultIT.java index 9429cac68fd..c2d3e552e04 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDefaultIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDefaultIT.java @@ -8,7 +8,7 @@ import org.hibernate.search.mapper.pojo.standalone.schema.management.SchemaManagementStrategyName; -public class SchemaManagementStrategyDefaultIT extends SchemaManagementStrategyCreateOrValidateIT { +class SchemaManagementStrategyDefaultIT extends SchemaManagementStrategyCreateOrValidateIT { @Override protected SchemaManagementStrategyName getStrategyName() { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDropAndCreateAndDropIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDropAndCreateAndDropIT.java index 04bd60d3640..b708ae4d83c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDropAndCreateAndDropIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDropAndCreateAndDropIT.java @@ -13,12 +13,12 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.CloseableSearchMapping; import org.hibernate.search.mapper.pojo.standalone.schema.management.SchemaManagementStrategyName; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SchemaManagementStrategyDropAndCreateAndDropIT extends AbstractSchemaManagementStrategyIT { +class SchemaManagementStrategyDropAndCreateAndDropIT extends AbstractSchemaManagementStrategyIT { @Override protected SchemaManagementStrategyName getStrategyName() { @@ -43,7 +43,7 @@ protected void expectOnClose(String indexName, CompletableFuture future) { } @Test - public void close_drop_exception_single() { + void close_drop_exception_single() { expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); expectWork( IndexedEntity2.NAME, CompletableFuture.completedFuture( null ) ); CloseableSearchMapping mapping = setup(); @@ -61,7 +61,7 @@ public void close_drop_exception_single() { } @Test - public void close_drop_exception_multiple() { + void close_drop_exception_multiple() { expectWork( IndexedEntity1.NAME, CompletableFuture.completedFuture( null ) ); expectWork( IndexedEntity2.NAME, CompletableFuture.completedFuture( null ) ); CloseableSearchMapping mapping = setup(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDropAndCreateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDropAndCreateIT.java index 42a33dd608f..e5aa311f680 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDropAndCreateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyDropAndCreateIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.strategy; import org.hibernate.search.mapper.pojo.standalone.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SchemaManagementStrategyDropAndCreateIT extends AbstractSchemaManagementStrategyIT { +class SchemaManagementStrategyDropAndCreateIT extends AbstractSchemaManagementStrategyIT { @Override protected SchemaManagementStrategyName getStrategyName() { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyNoneIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyNoneIT.java index bb86f393548..d1bc22a525d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyNoneIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyNoneIT.java @@ -13,23 +13,23 @@ import org.hibernate.search.mapper.pojo.standalone.cfg.StandalonePojoMapperSettings; import org.hibernate.search.mapper.pojo.standalone.mapping.CloseableSearchMapping; import org.hibernate.search.mapper.pojo.standalone.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SchemaManagementStrategyNoneIT { +class SchemaManagementStrategyNoneIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void none() { + void none() { CloseableSearchMapping mapper = setup(); // Nothing should have happened backendMock.verifyExpectationsMet(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyValidateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyValidateIT.java index 4421bd7f6ac..249382fd8a6 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyValidateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/schema/management/strategy/SchemaManagementStrategyValidateIT.java @@ -7,10 +7,10 @@ package org.hibernate.search.integrationtest.mapper.pojo.schema.management.strategy; import org.hibernate.search.mapper.pojo.standalone.schema.management.SchemaManagementStrategyName; -import org.hibernate.search.util.impl.integrationtest.common.rule.SchemaManagementWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.SchemaManagementWorkBehavior; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubSchemaManagementWork; -public class SchemaManagementStrategyValidateIT extends AbstractSchemaManagementStrategyValidatingIT { +class SchemaManagementStrategyValidateIT extends AbstractSchemaManagementStrategyValidatingIT { @Override protected SchemaManagementStrategyName getStrategyName() { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/scope/ScopeExtensionIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/scope/ScopeExtensionIT.java index 81393839616..b9213540866 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/scope/ScopeExtensionIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/scope/ScopeExtensionIT.java @@ -16,34 +16,34 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.impl.StubIndexScope; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ScopeExtensionIT { +class ScopeExtensionIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( IndexedEntity.NAME ); mapping = setupHelper.start().setup( IndexedEntity.class ); backendMock.verifyExpectationsMet(); } @Test - public void test() { + void test() { IndexScope indexScope = mapping.scope( IndexedEntity.class ).extension( original -> original ); assertThat( indexScope ).isInstanceOf( StubIndexScope.class ); } diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/SearchQueryBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/SearchQueryBaseIT.java index ddcc3d8ab54..c7192077cbd 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/SearchQueryBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/SearchQueryBaseIT.java @@ -28,13 +28,13 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.PropertyValue; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test everything related to the search query itself. @@ -42,19 +42,19 @@ * Does not test sorts and predicates, or other features that only involve the backend. * Those should be tested in the backend integration tests. */ -public class SearchQueryBaseIT { +class SearchQueryBaseIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Book.NAME ); backendMock.expectAnySchema( Author.NAME ); @@ -66,7 +66,7 @@ public void setup() { } @Test - public void target_byClass_singleType() { + void target_byClass_singleType() { try ( SearchSession searchSession = mapping.createSession() ) { SearchQuery query = searchSession.search( Book.class ) .selectEntityReference() @@ -93,7 +93,7 @@ public void target_byClass_singleType() { } @Test - public void target_byClass_multipleTypes() { + void target_byClass_multipleTypes() { try ( SearchSession searchSession = mapping.createSession() ) { SearchQuery query = searchSession.search( Arrays.asList( Book.class, Author.class ) ) .selectEntityReference() @@ -118,7 +118,7 @@ public void target_byClass_multipleTypes() { } @Test - public void target_byClass_invalidClass() { + void target_byClass_invalidClass() { try ( SearchSession searchSession = mapping.createSession() ) { Class invalidClass = String.class; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/AbstractSearchQueryEntityLoadingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/AbstractSearchQueryEntityLoadingIT.java index dbd4776c2ea..c3c2793658e 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/AbstractSearchQueryEntityLoadingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/AbstractSearchQueryEntityLoadingIT.java @@ -22,20 +22,20 @@ import org.hibernate.search.integrationtest.mapper.pojo.testsupport.loading.StubLoadingContext; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; +import org.junit.jupiter.api.extension.RegisterExtension; import org.assertj.core.api.SoftAssertions; public abstract class AbstractSearchQueryEntityLoadingIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/AbstractSearchQueryEntityLoadingSingleTypeIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/AbstractSearchQueryEntityLoadingSingleTypeIT.java index 7fb5231718b..30363dfa0e4 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/AbstractSearchQueryEntityLoadingSingleTypeIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/AbstractSearchQueryEntityLoadingSingleTypeIT.java @@ -13,7 +13,7 @@ import org.hibernate.search.integrationtest.mapper.pojo.testsupport.loading.StubSelectionLoadingStrategy; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.assertj.core.api.SoftAssertions; @@ -21,8 +21,8 @@ public abstract class AbstractSearchQueryEntityLoadingSingleTypeIT extends Abstr private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( BasicIndexedEntity.NAME ); mapping = setupHelper.start() diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingBaseIT.java index a5fa6db34f2..d139dd6b6e2 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingBaseIT.java @@ -9,19 +9,19 @@ import org.hibernate.search.integrationtest.mapper.pojo.search.loading.model.singletype.BasicIndexedEntity; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Basic tests of entity loading when executing a search query * when only a single type is involved. */ -public class SearchQueryEntityLoadingBaseIT extends AbstractSearchQueryEntityLoadingSingleTypeIT { +class SearchQueryEntityLoadingBaseIT extends AbstractSearchQueryEntityLoadingSingleTypeIT { /** * Test loading without any specific configuration. */ @Test - public void simple() { + void simple() { final int entityCount = 3; persistThatManyEntities( entityCount ); @@ -41,7 +41,7 @@ public void simple() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3349") - public void notFound() { + void notFound() { persistThatManyEntities( 2 ); testLoading( diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingFallbackToProjectionConstructorIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingFallbackToProjectionConstructorIT.java index d6f86b77097..9b217d136c3 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingFallbackToProjectionConstructorIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingFallbackToProjectionConstructorIT.java @@ -24,35 +24,35 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ProjectionConstructor; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; import org.hibernate.search.util.impl.test.data.Pair; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Test the fallback to projection constructors for the "default projection" (no select() call) * when no loader is registered for the loaded type. */ @TestForIssue(jiraKey = "HSEARCH-4579") -public class SearchQueryEntityLoadingFallbackToProjectionConstructorIT { +class SearchQueryEntityLoadingFallbackToProjectionConstructorIT { private static final String ENTITY_NAME = "entity_name"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); protected final StubLoadingContext loadingContext = new StubLoadingContext(); @Test - public void withoutLoadingStrategy_withoutProjectionConstructor() { + void withoutLoadingStrategy_withoutProjectionConstructor() { @Indexed class IndexedEntity { @DocumentId @@ -96,7 +96,7 @@ class IndexedEntity { } @Test - public void withoutLoadingStrategy_withProjectionConstructor() { + void withoutLoadingStrategy_withProjectionConstructor() { @Indexed class IndexedEntity { @DocumentId @@ -144,7 +144,7 @@ public IndexedEntity(@IdProjection Integer id, String text) { @Test - public void withLoadingStrategy_withProjectionConstructor() { + void withLoadingStrategy_withProjectionConstructor() { @Indexed class IndexedEntity { @DocumentId @@ -214,7 +214,7 @@ public IndexedEntity(@IdProjection Integer id, String text) { } @Test - public void multiType() { + void multiType() { class Model { @Indexed class IndexedEntityWithLoadingStrategy { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingMultipleTypesIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingMultipleTypesIT.java index b22a47e5e87..c63619d48e1 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingMultipleTypesIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingMultipleTypesIT.java @@ -34,14 +34,14 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test entity loading when executing a search query * for cases involving multiple entity types. */ -public class SearchQueryEntityLoadingMultipleTypesIT extends AbstractSearchQueryEntityLoadingIT { +class SearchQueryEntityLoadingMultipleTypesIT extends AbstractSearchQueryEntityLoadingIT { private SearchMapping mapping; @@ -50,8 +50,8 @@ protected SearchMapping mapping() { return mapping; } - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( Hierarchy1_A_B.NAME ); backendMock.expectAnySchema( Hierarchy1_A_C.NAME ); @@ -133,7 +133,7 @@ public void setup() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3349") - public void singleHierarchy() { + void singleHierarchy() { testLoading( Arrays.asList( Hierarchy1_A_B.class, @@ -160,7 +160,7 @@ public void singleHierarchy() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3349") - public void singleHierarchy_middleMappedSuperClass() { + void singleHierarchy_middleMappedSuperClass() { testLoading( Arrays.asList( Hierarchy5_A_B_C.class, @@ -187,7 +187,7 @@ public void singleHierarchy_middleMappedSuperClass() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3349") - public void mixedHierarchies() { + void mixedHierarchies() { testLoading( Arrays.asList( Hierarchy1_A_B.class, @@ -233,7 +233,7 @@ public void mixedHierarchies() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3203") - public void mixedDocumentIdMapping_entityIdAndProperty_mixedHierarchies() { + void mixedDocumentIdMapping_entityIdAndProperty_mixedHierarchies() { testLoading( Arrays.asList( Hierarchy4_A_B__integer1DocumentId.class, @@ -259,7 +259,7 @@ public void mixedDocumentIdMapping_entityIdAndProperty_mixedHierarchies() { */ @Test @TestForIssue(jiraKey = { "HSEARCH-3203", "HSEARCH-3349" }) - public void mixedDocumentIdMapping_entityIdAndProperty_singleHierarchy() { + void mixedDocumentIdMapping_entityIdAndProperty_singleHierarchy() { testLoading( Arrays.asList( Hierarchy4_A_B__integer1DocumentId.class, @@ -286,7 +286,7 @@ public void mixedDocumentIdMapping_entityIdAndProperty_singleHierarchy() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3203") - public void mixedDocumentIdMapping_differentProperty() { + void mixedDocumentIdMapping_differentProperty() { testLoading( Arrays.asList( Hierarchy4_A_B__integer1DocumentId.class, @@ -325,7 +325,7 @@ public void mixedDocumentIdMapping_differentProperty() { */ @Test @TestForIssue(jiraKey = "HSEARCH-3349") - public void typeChanged() { + void typeChanged() { testLoading( Arrays.asList( Interface1.class ), // Implemented by B and C, but not D Arrays.asList( diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingScrollingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingScrollingIT.java index f5b5a4c0e9c..d4e41c86105 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingScrollingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/search/loading/SearchQueryEntityLoadingScrollingIT.java @@ -12,9 +12,9 @@ import org.hibernate.search.engine.search.query.SearchQuery; import org.hibernate.search.engine.search.query.SearchScroll; import org.hibernate.search.engine.search.query.SearchScrollResult; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubNextScrollWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubNextScrollWorkBehavior; -public class SearchQueryEntityLoadingScrollingIT extends SearchQueryEntityLoadingBaseIT { +class SearchQueryEntityLoadingScrollingIT extends SearchQueryEntityLoadingBaseIT { @Override protected List getHits(List targetIndexes, SearchQuery query, diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/smoke/AnnotationMappingSmokeIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/smoke/AnnotationMappingSmokeIT.java index ebaa42e3d6d..14a908a5c8c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/smoke/AnnotationMappingSmokeIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/smoke/AnnotationMappingSmokeIT.java @@ -41,27 +41,27 @@ import org.hibernate.search.mapper.pojo.standalone.scope.SearchScope; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class AnnotationMappingSmokeIT { +class AnnotationMappingSmokeIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( OtherIndexedEntity.INDEX, b -> b .field( "numeric", Integer.class ) .field( "numericAsString", String.class ) @@ -155,7 +155,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity(); entity1.setId( 1 ); @@ -345,7 +345,7 @@ public void index() { } @Test - public void search() { + void search() { try ( SearchSession session = mapping.createSession() ) { SearchQuery query = session.search( Arrays.asList( IndexedEntity.class, YetAnotherIndexedEntity.class ) @@ -380,7 +380,7 @@ public void search() { @Test - public void search_singleElementProjection() { + void search_singleElementProjection() { try ( SearchSession session = mapping.createSession() ) { SearchQuery query = session.search( Arrays.asList( IndexedEntity.class, YetAnotherIndexedEntity.class ) @@ -414,7 +414,7 @@ public void search_singleElementProjection() { } @Test - public void search_multipleElementsProjection() { + void search_multipleElementsProjection() { SearchScope scope = mapping.scope( Arrays.asList( IndexedEntity.class, YetAnotherIndexedEntity.class ) ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/smoke/ProgrammaticMappingSmokeIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/smoke/ProgrammaticMappingSmokeIT.java index d0d0ab3d7b3..f6e52038cc1 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/smoke/ProgrammaticMappingSmokeIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/smoke/ProgrammaticMappingSmokeIT.java @@ -33,27 +33,27 @@ import org.hibernate.search.mapper.pojo.standalone.scope.SearchScope; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProgrammaticMappingSmokeIT { +class ProgrammaticMappingSmokeIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( OtherIndexedEntity.INDEX, b -> b .field( "numeric", Integer.class ) .field( "numericAsString", String.class ) @@ -205,7 +205,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity(); entity1.setId( 1 ); @@ -396,7 +396,7 @@ public void index() { } @Test - public void search() { + void search() { try ( SearchSession session = mapping.createSession() ) { SearchQuery query = session.search( Arrays.asList( IndexedEntity.class, YetAnotherIndexedEntity.class ) @@ -431,7 +431,7 @@ public void search() { } @Test - public void search_singleElementProjection() { + void search_singleElementProjection() { try ( SearchSession session = mapping.createSession() ) { SearchQuery query = session.search( Arrays.asList( IndexedEntity.class, YetAnotherIndexedEntity.class ) @@ -465,7 +465,7 @@ public void search_singleElementProjection() { } @Test - public void search_multipleElementsProjection() { + void search_multipleElementsProjection() { SearchScope scope = mapping.scope( Arrays.asList( IndexedEntity.class, YetAnotherIndexedEntity.class ) ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/spatial/AnnotationMappingGeoPointBindingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/spatial/AnnotationMappingGeoPointBindingIT.java index 2544bdadd51..64343061da0 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/spatial/AnnotationMappingGeoPointBindingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/spatial/AnnotationMappingGeoPointBindingIT.java @@ -19,26 +19,26 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class AnnotationMappingGeoPointBindingIT { +class AnnotationMappingGeoPointBindingIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( GeoPointOnTypeEntity.INDEX, b -> b .field( "homeLocation", GeoPoint.class, b2 -> b2.projectable( Projectable.YES ).sortable( Sortable.YES ) ) .field( "workLocation", GeoPoint.class, @@ -68,7 +68,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { GeoPointOnTypeEntity entity1 = new GeoPointOnTypeEntity(); entity1.id = 1; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/spatial/ProgrammaticMappingGeoPointBindingIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/spatial/ProgrammaticMappingGeoPointBindingIT.java index 36604519e07..ee7e4bb6215 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/spatial/ProgrammaticMappingGeoPointBindingIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/spatial/ProgrammaticMappingGeoPointBindingIT.java @@ -17,26 +17,26 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProgrammaticMappingGeoPointBindingIT { +class ProgrammaticMappingGeoPointBindingIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( GeoPointOnTypeEntity.INDEX, b -> b .field( "homeLocation", GeoPoint.class, b2 -> b2.projectable( Projectable.YES ).sortable( Sortable.YES ) ) .field( "workLocation", GeoPoint.class, @@ -115,7 +115,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { GeoPointOnTypeEntity entity1 = new GeoPointOnTypeEntity(); entity1.id = 1; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/types/JavaNetURLPropertyTypeDescriptor.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/types/JavaNetURLPropertyTypeDescriptor.java index 763b824daa4..afb2332a3f6 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/types/JavaNetURLPropertyTypeDescriptor.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/types/JavaNetURLPropertyTypeDescriptor.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.pojo.testsupport.types; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.fail; import java.net.MalformedURLException; import java.net.URI; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/CloseCountingBeanHolder.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/CloseCountingBeanHolder.java index 5d1a8bd77a4..6e59d2419a9 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/CloseCountingBeanHolder.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/CloseCountingBeanHolder.java @@ -7,7 +7,7 @@ package org.hibernate.search.integrationtest.mapper.pojo.testsupport.util; import org.hibernate.search.engine.environment.bean.BeanHolder; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; public class CloseCountingBeanHolder implements BeanHolder { private final T bean; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/StartupStubBridge.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/StartupStubBridge.java index 41590884228..d19e4c6e8cf 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/StartupStubBridge.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/StartupStubBridge.java @@ -31,7 +31,7 @@ import org.hibernate.search.mapper.pojo.bridge.runtime.ValueBridgeToIndexedValueContext; import org.hibernate.search.mapper.pojo.route.DocumentRoutes; import org.hibernate.search.util.common.AssertionFailure; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; /** * A stub bridge for use in tests where the bridge is only used on startup. diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/StartupStubContainerExtractor.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/StartupStubContainerExtractor.java index 8707d50cb2a..03dfc4b97b8 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/StartupStubContainerExtractor.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/testsupport/util/StartupStubContainerExtractor.java @@ -11,7 +11,7 @@ import org.hibernate.search.mapper.pojo.extractor.ContainerExtractor; import org.hibernate.search.mapper.pojo.extractor.ValueProcessor; import org.hibernate.search.util.common.AssertionFailure; -import org.hibernate.search.util.impl.test.rule.StaticCounters; +import org.hibernate.search.util.impl.test.extension.StaticCounters; /** * A stub container value extractors for use in tests where the extractor is only used on startup. diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/timeout/SearchTimeoutIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/timeout/SearchTimeoutIT.java index 92211202380..4b5b9c39138 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/timeout/SearchTimeoutIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/timeout/SearchTimeoutIT.java @@ -21,36 +21,36 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; -import org.hibernate.search.util.impl.integrationtest.common.rule.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class SearchTimeoutIT { +class SearchTimeoutIT { private static final String INDEX_NAME = "IndexName"; - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( INDEX_NAME, b -> b.field( "keyword", String.class ) ); mapping = setupHelper.start().setup( IndexedEntity.class ); backendMock.verifyExpectationsMet(); } @Test - public void truncateAfter() { + void truncateAfter() { try ( SearchSession session = mapping.createSession() ) { SearchQuery query = session.search( IndexedEntity.class ) .selectEntityReference() @@ -70,7 +70,7 @@ public void truncateAfter() { } @Test - public void failAfter() { + void failAfter() { try ( SearchSession session = mapping.createSession() ) { SearchQuery query = session.search( IndexedEntity.class ) .selectEntityReference() diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/PojoIndexingPlanBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/PojoIndexingPlanBaseIT.java index 7b6ce3b0144..4ad7aede24c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/PojoIndexingPlanBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/PojoIndexingPlanBaseIT.java @@ -28,17 +28,18 @@ import org.hibernate.search.mapper.pojo.standalone.loading.SelectionLoadingStrategy; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; /** @@ -48,25 +49,24 @@ * see {@code org.hibernate.search.integrationtest.mapper.orm.session.SearchIndexingPlanBaseIT} * in particular. */ -public class PojoIndexingPlanBaseIT { +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class PojoIndexingPlanBaseIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock private SelectionEntityLoader loaderMock; private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "value", String.class ) .objectField( "contained", b2 -> b2 @@ -84,7 +84,7 @@ public void setup() { } @Test - public void simple() { + void simple() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity( 1 ); IndexedEntity entity2 = new IndexedEntity( 2 ); @@ -119,7 +119,7 @@ public void simple() { * Test the state inside indexing plans. */ @Test - public void state() { + void state() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity; @@ -191,7 +191,7 @@ public void state() { } @Test - public void dirtyPaths_root() { + void dirtyPaths_root() { IndexedEntity indexed = new IndexedEntity( 1 ); // Update with relevant dirty path @@ -227,7 +227,7 @@ public void dirtyPaths_root() { } @Test - public void dirtyPaths_contained() { + void dirtyPaths_contained() { IndexedEntity indexed = new IndexedEntity( 1 ); ContainedEntity contained = new ContainedEntity( 2 ); indexed.contained = contained; @@ -286,7 +286,7 @@ public void dirtyPaths_contained() { * Test when the entity is null and must be loaded. */ @Test - public void nullEntity() { + void nullEntity() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity( 1 ); IndexedEntity entity2 = new IndexedEntity( 2 ); @@ -323,7 +323,7 @@ public void nullEntity() { * Test the state inside indexing plans when the entity is null and must be loaded. */ @Test - public void nullEntity_state() { + void nullEntity_state() { List idsToLoad = new ArrayList<>(); List loadedEntities = new ArrayList<>(); @@ -414,7 +414,7 @@ public void nullEntity_state() { } @Test - public void failure() { + void failure() { RuntimeException simulatedFailure = new RuntimeException( "Indexing failure" ); assertThatThrownBy( () -> { try ( SearchSession session = mapping.createSession() ) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/PojoIndexingPlanSynchronizationStrategyIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/PojoIndexingPlanSynchronizationStrategyIT.java index 170d9c2d440..dd4d631afdc 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/PojoIndexingPlanSynchronizationStrategyIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/PojoIndexingPlanSynchronizationStrategyIT.java @@ -16,26 +16,26 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class PojoIndexingPlanSynchronizationStrategyIT { +class PojoIndexingPlanSynchronizationStrategyIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectAnySchema( IndexedEntity.NAME ); mapping = setupHelper.start() @@ -44,7 +44,7 @@ public void setup() { } @Test - public void overrideIndexingPlanSyncStrategy() { + void overrideIndexingPlanSyncStrategy() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity(); entity1.setId( 1 ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerAddOrUpdateNullEntityIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerAddOrUpdateNullEntityIT.java index d936ab972b8..4b370c0ab76 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerAddOrUpdateNullEntityIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerAddOrUpdateNullEntityIT.java @@ -8,12 +8,16 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; +import org.hibernate.search.engine.backend.work.execution.DocumentCommitStrategy; +import org.hibernate.search.engine.backend.work.execution.DocumentRefreshStrategy; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexer; +import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests of individual operations in {@link org.hibernate.search.mapper.pojo.work.spi.PojoIndexer} @@ -22,8 +26,11 @@ @TestForIssue(jiraKey = "HSEARCH-4153") public abstract class AbstractPojoIndexerAddOrUpdateNullEntityIT extends AbstractPojoIndexingOperationIT { - @Test - public void simple() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void simple(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); try ( SearchSession session = createSession() ) { SearchIndexer indexer = session.indexer(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerDeleteNullEntityIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerDeleteNullEntityIT.java index d2a5418a457..a3ce775aaed 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerDeleteNullEntityIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerDeleteNullEntityIT.java @@ -15,14 +15,18 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; +import org.hibernate.search.engine.backend.work.execution.DocumentCommitStrategy; +import org.hibernate.search.engine.backend.work.execution.DocumentRefreshStrategy; import org.hibernate.search.mapper.pojo.route.DocumentRouteDescriptor; import org.hibernate.search.mapper.pojo.route.DocumentRoutesDescriptor; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexer; +import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests of individual operations in {@link org.hibernate.search.mapper.pojo.work.spi.PojoIndexer} @@ -31,8 +35,11 @@ @TestForIssue(jiraKey = "HSEARCH-4153") public abstract class AbstractPojoIndexerDeleteNullEntityIT extends AbstractPojoIndexingOperationIT { - @Test - public void simple() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void simple(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); try ( SearchSession session = createSession() ) { SearchIndexer indexer = session.indexer(); @@ -47,8 +54,11 @@ public void simple() { } } - @Test - public void nullProvidedId() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void nullProvidedId(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); try ( SearchSession session = createSession() ) { SearchIndexer indexer = session.indexer(); @@ -59,8 +69,12 @@ public void nullProvidedId() { } } - @Test - public void providedId_providedRoutes_currentAndNoPrevious() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId_providedRoutes_currentAndNoPrevious(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexer indexer = session.indexer(); @@ -77,8 +91,12 @@ public void providedId_providedRoutes_currentAndNoPrevious() { } } - @Test - public void providedId_providedRoutes_currentAndPrevious() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId_providedRoutes_currentAndPrevious(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexer indexer = session.indexer(); @@ -108,8 +126,11 @@ public void providedId_providedRoutes_currentAndPrevious() { } } - @Test - public void runtimeException() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void runtimeException(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); RuntimeException exception = new RuntimeException(); try ( SearchSession session = createSession() ) { @@ -125,8 +146,11 @@ public void runtimeException() { } } - @Test - public void error() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void error(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); Error error = new Error(); try ( SearchSession session = createSession() ) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerOperationBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerOperationBaseIT.java index 92917026894..2d58f02180c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerOperationBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexerOperationBaseIT.java @@ -14,21 +14,28 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; +import org.hibernate.search.engine.backend.work.execution.DocumentCommitStrategy; +import org.hibernate.search.engine.backend.work.execution.DocumentRefreshStrategy; import org.hibernate.search.mapper.pojo.route.DocumentRouteDescriptor; import org.hibernate.search.mapper.pojo.route.DocumentRoutesDescriptor; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexer; +import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests of individual operations in {@link org.hibernate.search.mapper.pojo.work.spi.PojoIndexer}. */ public abstract class AbstractPojoIndexerOperationBaseIT extends AbstractPojoIndexingOperationIT { - @Test - public void success() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void success(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexer indexer = session.indexer(); @@ -43,8 +50,11 @@ public void success() { } } - @Test - public void providedId() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexer indexer = session.indexer(); @@ -59,8 +69,12 @@ public void providedId() { } } - @Test - public void providedId_providedRoutes_currentAndNoPrevious() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId_providedRoutes_currentAndNoPrevious(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexer indexer = session.indexer(); @@ -102,8 +116,12 @@ public void providedId_providedRoutes_currentAndNoPrevious() { } } - @Test - public void providedId_providedRoutes_currentAndPrevious() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId_providedRoutes_currentAndPrevious(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexer indexer = session.indexer(); @@ -149,9 +167,12 @@ public void providedId_providedRoutes_currentAndPrevious() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void previouslyIndexedWithDifferentRoute() { + void previouslyIndexedWithDifferentRoute(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -180,9 +201,12 @@ public void previouslyIndexedWithDifferentRoute() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void previouslyIndexedWithMultipleRoutes() { + void previouslyIndexedWithMultipleRoutes(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -216,9 +240,12 @@ public void previouslyIndexedWithMultipleRoutes() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void notIndexed_notPreviouslyIndexed() { + void notIndexed_notPreviouslyIndexed(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); try ( SearchSession session = createSession() ) { @@ -233,9 +260,13 @@ public void notIndexed_notPreviouslyIndexed() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void notIndexed_previouslyIndexedWithDifferentRoute() { + void notIndexed_previouslyIndexedWithDifferentRoute(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); try ( SearchSession session = createSession() ) { @@ -256,9 +287,13 @@ public void notIndexed_previouslyIndexedWithDifferentRoute() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void notIndexed_previouslyIndexedWithMultipleRoutes() { + void notIndexed_previouslyIndexedWithMultipleRoutes(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); try ( SearchSession session = createSession() ) { @@ -286,8 +321,11 @@ public void notIndexed_previouslyIndexedWithMultipleRoutes() { } } - @Test - public void runtimeException() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void runtimeException(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); RuntimeException exception = new RuntimeException(); try ( SearchSession session = createSession() ) { @@ -303,8 +341,11 @@ public void runtimeException() { } } - @Test - public void error() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void error(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); Error error = new Error(); try ( SearchSession session = createSession() ) { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingOperationIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingOperationIT.java index 9877a88dbbb..d54aee62846 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingOperationIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingOperationIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.pojo.work.operations; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.Mockito.when; import java.lang.invoke.MethodHandles; @@ -24,28 +24,27 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.provider.Arguments; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; /** * Abstract base for {@link AbstractPojoIndexingPlanOperationBaseIT} * and {@link AbstractPojoIndexerOperationBaseIT} */ -@RunWith(Parameterized.class) +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) public abstract class AbstractPojoIndexingOperationIT { - @Parameterized.Parameters(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") - public static List parameters() { + public static List params() { Object[][] strategies = new Object[][] { new Object[] { DocumentCommitStrategy.NONE, @@ -65,36 +64,28 @@ public static List parameters() { IndexingPlanSynchronizationStrategy.sync() } }; - List params = new ArrayList<>(); + List params = new ArrayList<>(); MyRoutingBinder routingBinder = new MyRoutingBinder(); for ( Object[] strategy : strategies ) { - params.add( new Object[] { strategy[0], strategy[1], null, null, strategy[2] } ); - params.add( new Object[] { strategy[0], strategy[1], null, routingBinder, strategy[2] } ); - params.add( new Object[] { strategy[0], strategy[1], "tenant1", null, strategy[2] } ); - params.add( new Object[] { strategy[0], strategy[1], "tenant1", routingBinder, strategy[2] } ); + params.add( Arguments.of( strategy[0], strategy[1], null, null, strategy[2] ) ); + params.add( Arguments.of( strategy[0], strategy[1], null, routingBinder, strategy[2] ) ); + params.add( Arguments.of( strategy[0], strategy[1], "tenant1", null, strategy[2] ) ); + params.add( Arguments.of( strategy[0], strategy[1], "tenant1", routingBinder, strategy[2] ) ); } return params; } - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - - @Parameterized.Parameter public DocumentCommitStrategy commitStrategy; - @Parameterized.Parameter(1) public DocumentRefreshStrategy refreshStrategy; - @Parameterized.Parameter(2) public String tenantId; - @Parameterized.Parameter(3) public MyRoutingBinder routingBinder; - @Parameterized.Parameter(4) public IndexingPlanSynchronizationStrategy strategy; protected SearchMapping mapping; @@ -105,8 +96,13 @@ public static List parameters() { @Mock private SelectionEntityLoader containedEntityLoaderMock; - @Before - public void setup() { + public void setup(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + this.commitStrategy = commitStrategy; + this.refreshStrategy = refreshStrategy; + this.tenantId = tenantId; + this.routingBinder = routingBinder; + this.strategy = strategy; backendMock.expectSchema( IndexedEntity.INDEX, b -> b .field( "value", String.class ) .objectField( "contained", b2 -> b2 @@ -147,9 +143,11 @@ protected final boolean isDelete() { protected abstract boolean isImplicitRoutingEnabled(); protected final void assumeImplicitRoutingEnabled() { - assumeTrue( "This test only makes sense when a routing bridge is configured and " - + "the operation takes the routing bridge into account", - isImplicitRoutingEnabled() ); + assumeTrue( + isImplicitRoutingEnabled(), + "This test only makes sense when a routing bridge is configured and " + + "the operation takes the routing bridge into account" + ); } protected final SearchSession createSession() { diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationBaseIT.java index bb289ac0e77..f50c2ca1cb8 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationBaseIT.java @@ -19,13 +19,15 @@ import org.hibernate.search.mapper.pojo.route.DocumentRoutesDescriptor; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.ExceptionMatcherBuilder; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.hibernate.search.util.impl.test.rule.ExpectedLog4jLog; +import org.hibernate.search.util.impl.test.extension.ExpectedLog4jLog; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.apache.logging.log4j.Level; @@ -34,11 +36,14 @@ */ public abstract class AbstractPojoIndexingPlanOperationBaseIT extends AbstractPojoIndexingOperationIT { - @Rule + @RegisterExtension public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); - @Test - public void simple() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void simple(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -50,8 +55,11 @@ public void simple() { } } - @Test - public void providedId() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -63,8 +71,12 @@ public void providedId() { } } - @Test - public void providedId_providedRoutes_currentAndNoPrevious() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId_providedRoutes_currentAndNoPrevious(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -103,8 +115,12 @@ public void providedId_providedRoutes_currentAndNoPrevious() { } } - @Test - public void providedId_providedRoutes_currentAndPrevious() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId_providedRoutes_currentAndPrevious(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -148,9 +164,13 @@ public void providedId_providedRoutes_currentAndPrevious() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-4538") - public void providedId_providedRoutes_noCurrentAndPrevious() { + void providedId_providedRoutes_noCurrentAndPrevious(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -211,9 +231,12 @@ public void providedId_providedRoutes_noCurrentAndPrevious() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void previouslyIndexedWithDifferentRoute() { + void previouslyIndexedWithDifferentRoute(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -241,9 +264,12 @@ public void previouslyIndexedWithDifferentRoute() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void previouslyIndexedWithMultipleRoutes() { + void previouslyIndexedWithMultipleRoutes(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -273,9 +299,12 @@ public void previouslyIndexedWithMultipleRoutes() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void notIndexed_notPreviouslyIndexed() { + void notIndexed_notPreviouslyIndexed(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); try ( SearchSession session = createSession() ) { @@ -288,9 +317,13 @@ public void notIndexed_notPreviouslyIndexed() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void notIndexed_previouslyIndexedWithDifferentRoute() { + void notIndexed_previouslyIndexedWithDifferentRoute(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -314,9 +347,13 @@ public void notIndexed_previouslyIndexedWithDifferentRoute() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void notIndexed_previouslyIndexedWithMultipleRoutes() { + void notIndexed_previouslyIndexedWithMultipleRoutes(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -345,9 +382,12 @@ public void notIndexed_previouslyIndexedWithMultipleRoutes() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void runtimeException() { + void runtimeException(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); RuntimeException exception = new RuntimeException(); @@ -365,8 +405,11 @@ public void runtimeException() { assertExceptionalSituation( work, exception ); } - @Test - public void error() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void error(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); Error error = new Error(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationContainedNullEntityIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationContainedNullEntityIT.java index 95fb762fcb2..c178a39e761 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationContainedNullEntityIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationContainedNullEntityIT.java @@ -7,20 +7,24 @@ package org.hibernate.search.integrationtest.mapper.pojo.work.operations; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Arrays; import java.util.Collections; import java.util.concurrent.CompletableFuture; +import org.hibernate.search.engine.backend.work.execution.DocumentCommitStrategy; +import org.hibernate.search.engine.backend.work.execution.DocumentRefreshStrategy; import org.hibernate.search.mapper.pojo.route.DocumentRouteDescriptor; import org.hibernate.search.mapper.pojo.route.DocumentRoutesDescriptor; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; +import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests of individual operations in {@link org.hibernate.search.mapper.pojo.work.spi.PojoIndexingPlan} @@ -29,8 +33,11 @@ @TestForIssue(jiraKey = "HSEARCH-4141") public abstract class AbstractPojoIndexingPlanOperationContainedNullEntityIT extends AbstractPojoIndexingOperationIT { - @Test - public void simple() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void simple(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -46,8 +53,11 @@ public void simple() { } } - @Test - public void loadingDoesNotFindEntity() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void loadingDoesNotFindEntity(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitLoading(); try ( SearchSession session = createSession() ) { @@ -60,8 +70,11 @@ public void loadingDoesNotFindEntity() { } } - @Test - public void nullProvidedId() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void nullProvidedId(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); assertThatThrownBy( () -> scenario().addWithoutInstanceTo( indexingPlan, ContainedEntity.class, null, null ) ) @@ -72,8 +85,11 @@ public void nullProvidedId() { } // Provided routes are ignored for contained types - @Test - public void providedId_providedRoutes() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId_providedRoutes(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -95,9 +111,12 @@ public void providedId_providedRoutes() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void containingNotIndexed() { + void containingNotIndexed(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); try ( SearchSession session = createSession() ) { @@ -117,9 +136,10 @@ protected boolean isImplicitRoutingEnabled() { } private void assumeImplicitLoading() { - assumeTrue( "This test only makes sense when " - + "the operation automatically loads entities", - !isDelete() ); + assumeTrue( + !isDelete(), + "This test only makes sense when the operation automatically loads entities" + ); } } diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationNullEntityIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationNullEntityIT.java index 5079cb32b03..c9b2ad2ef76 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationNullEntityIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingPlanOperationNullEntityIT.java @@ -8,20 +8,24 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.integrationtest.mapper.pojo.work.operations.BackendIndexingOperation.addWorkInfo; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Arrays; import java.util.Collections; import java.util.concurrent.CompletableFuture; +import org.hibernate.search.engine.backend.work.execution.DocumentCommitStrategy; +import org.hibernate.search.engine.backend.work.execution.DocumentRefreshStrategy; import org.hibernate.search.mapper.pojo.route.DocumentRouteDescriptor; import org.hibernate.search.mapper.pojo.route.DocumentRoutesDescriptor; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; +import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; /** * Tests of individual operations in {@link org.hibernate.search.mapper.pojo.work.spi.PojoIndexingPlan} @@ -30,8 +34,11 @@ @TestForIssue(jiraKey = "HSEARCH-4153") public abstract class AbstractPojoIndexingPlanOperationNullEntityIT extends AbstractPojoIndexingOperationIT { - @Test - public void simple() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void simple(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -44,12 +51,15 @@ public void simple() { } } - @Test - public void loadingDoesNotFindEntity() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void loadingDoesNotFindEntity(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeTrue( + scenario().expectSkipOnEntityAbsentAfterImplicitLoading(), "This test only makes sense when " - + "the operation is automatically skipped when the entity is absent upon implicit loading", - scenario().expectSkipOnEntityAbsentAfterImplicitLoading() + + "the operation is automatically skipped when the entity is absent upon implicit loading" ); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -64,8 +74,11 @@ public void loadingDoesNotFindEntity() { } } - @Test - public void nullProvidedId() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void nullProvidedId(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, String tenantId, + MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); assertThatThrownBy( () -> scenario().addWithoutInstanceTo( indexingPlan, IndexedEntity.class, null, null ) ) @@ -75,8 +88,12 @@ public void nullProvidedId() { } } - @Test - public void providedId_providedRoutes_currentAndNoPrevious() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId_providedRoutes_currentAndNoPrevious(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -116,8 +133,12 @@ public void providedId_providedRoutes_currentAndNoPrevious() { } } - @Test - public void providedId_providedRoutes_currentAndPrevious() { + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") + void providedId_providedRoutes_currentAndPrevious(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); CompletableFuture futureFromBackend = new CompletableFuture<>(); try ( SearchSession session = createSession() ) { SearchIndexingPlan indexingPlan = session.indexingPlan(); @@ -163,9 +184,12 @@ public void providedId_providedRoutes_currentAndPrevious() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void previouslyIndexedWithDifferentRoute() { + void previouslyIndexedWithDifferentRoute(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -194,9 +218,12 @@ public void previouslyIndexedWithDifferentRoute() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void previouslyIndexedWithMultipleRoutes() { + void previouslyIndexedWithMultipleRoutes(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -227,9 +254,12 @@ public void previouslyIndexedWithMultipleRoutes() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void notIndexed_notPreviouslyIndexed() { + void notIndexed_notPreviouslyIndexed(DocumentCommitStrategy commitStrategy, DocumentRefreshStrategy refreshStrategy, + String tenantId, MyRoutingBinder routingBinder, IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); try ( SearchSession session = createSession() ) { @@ -243,9 +273,13 @@ public void notIndexed_notPreviouslyIndexed() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void notIndexed_previouslyIndexedWithDifferentRoute() { + void notIndexed_previouslyIndexedWithDifferentRoute(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); @@ -270,9 +304,13 @@ public void notIndexed_previouslyIndexedWithDifferentRoute() { } } - @Test + @ParameterizedTest(name = "commit: {0}, refresh: {1}, tenantID: {2}, routing: {3}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3108") - public void notIndexed_previouslyIndexedWithMultipleRoutes() { + void notIndexed_previouslyIndexedWithMultipleRoutes(DocumentCommitStrategy commitStrategy, + DocumentRefreshStrategy refreshStrategy, String tenantId, MyRoutingBinder routingBinder, + IndexingPlanSynchronizationStrategy strategy) { + setup( commitStrategy, refreshStrategy, tenantId, routingBinder, strategy ); assumeImplicitRoutingEnabled(); CompletableFuture futureFromBackend = new CompletableFuture<>(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingProcessorFailureIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingProcessorFailureIT.java index e0bad3c4b0a..4cba1caf5c1 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingProcessorFailureIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoIndexingProcessorFailureIT.java @@ -22,34 +22,34 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) abstract class AbstractPojoIndexingProcessorFailureIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - protected SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( RootEntity.NAME, b -> b .field( "value", String.class ) .objectField( "containedNoContainer", b2 -> b2 @@ -74,7 +74,7 @@ public void setup() { } @Test - public void getter() { + void getter() { RootEntity root = new RootEntity(); root.id = 1; @@ -91,7 +91,7 @@ public void getter() { @Test @SuppressWarnings("unchecked") - public void containerExtraction() { + void containerExtraction() { RootEntity root = new RootEntity(); root.id = 1; root.containedInContainer = Mockito.mock( List.class ); @@ -108,7 +108,7 @@ public void containerExtraction() { } @Test - public void nested_getter() { + void nested_getter() { RootEntity root = new RootEntity(); root.id = 1; NonRootEntity level1 = new NonRootEntity(); @@ -128,7 +128,7 @@ public void nested_getter() { @Test @SuppressWarnings("unchecked") - public void nested_containerExtraction() { + void nested_containerExtraction() { RootEntity root = new RootEntity(); root.id = 1; NonRootEntity level1 = new NonRootEntity(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoReindexingResolutionFailureIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoReindexingResolutionFailureIT.java index 9f98f76c489..040ad7b0e99 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoReindexingResolutionFailureIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/AbstractPojoReindexingResolutionFailureIT.java @@ -22,34 +22,34 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.util.common.SearchException; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.RegisterExtension; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) abstract class AbstractPojoReindexingResolutionFailureIT { - @Rule - public final BackendMock backendMock = new BackendMock(); + @RegisterExtension + public final BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public final StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - protected SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( RootEntity.NAME, b -> b .field( "value", String.class ) .objectField( "containedNoContainer", b2 -> b2 @@ -74,7 +74,7 @@ public void setup() { } @Test - public void getter() { + void getter() { NonRootEntity level1 = new NonRootEntity(); SimulatedFailure simulatedFailure = new SimulatedFailure(); @@ -90,7 +90,7 @@ public void getter() { @Test @SuppressWarnings("unchecked") - public void containerExtraction() { + void containerExtraction() { NonRootEntity level1 = new NonRootEntity(); level1.containingInContainer = Mockito.mock( List.class ); @@ -106,7 +106,7 @@ public void containerExtraction() { } @Test - public void nested_getter() { + void nested_getter() { NonRootEntity level1 = new NonRootEntity(); SimulatedFailure simulatedFailure = new SimulatedFailure(); @@ -126,7 +126,7 @@ public void nested_getter() { @Test @SuppressWarnings("unchecked") - public void nested_containerExtraction() { + void nested_containerExtraction() { NonRootEntity level1 = new NonRootEntity(); level1.containingInContainer = Mockito.mock( List.class ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/BackendIndexingOperation.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/BackendIndexingOperation.java index 56012becca2..835da9db87d 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/BackendIndexingOperation.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/BackendIndexingOperation.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.pojo.work.operations; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.document.StubDocumentNode; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.index.StubDocumentWork; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddIT.java index 8efadaca6ca..83931f57cb4 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddIT.java @@ -12,13 +12,10 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexer; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; -@RunWith(NestedRunner.class) -public class PojoIndexingAddIT { +class PojoIndexingAddIT { private static final PojoIndexingOperationScenario SCENARIO = new PojoIndexingOperationScenario( BackendIndexingOperation.ADD ) { @@ -62,7 +59,7 @@ CompletionStage execute(SearchIndexer indexer, Object providedId, DocumentRou }; @Nested - public static class IndexerBaseIT extends AbstractPojoIndexerOperationBaseIT { + class IndexerBaseIT extends AbstractPojoIndexerOperationBaseIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -70,7 +67,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexerNullEntityIT extends AbstractPojoIndexerAddOrUpdateNullEntityIT { + class IndexerNullEntityIT extends AbstractPojoIndexerAddOrUpdateNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -78,7 +75,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexerIndexingProcessorFailureIT extends AbstractPojoIndexingProcessorFailureIT { + class IndexerIndexingProcessorFailureIT extends AbstractPojoIndexingProcessorFailureIT { @Override protected void process(SearchSession session, Object entity) { session.indexer().add( entity ); @@ -86,7 +83,7 @@ protected void process(SearchSession session, Object entity) { } @Nested - public static class IndexingPlanBaseIT extends AbstractPojoIndexingPlanOperationBaseIT { + class IndexingPlanBaseIT extends AbstractPojoIndexingPlanOperationBaseIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -94,7 +91,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { + class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -102,7 +99,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { + class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -110,7 +107,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanIndexingProcessorFailureIT extends AbstractPojoIndexingProcessorFailureIT { + class IndexingPlanIndexingProcessorFailureIT extends AbstractPojoIndexingProcessorFailureIT { @Override protected void process(SearchSession session, Object entity) { session.indexingPlan().add( entity ); @@ -119,7 +116,7 @@ protected void process(SearchSession session, Object entity) { } @Nested - public static class IndexingPlanReindexingResolutionFailureIT extends AbstractPojoReindexingResolutionFailureIT { + class IndexingPlanReindexingResolutionFailureIT extends AbstractPojoReindexingResolutionFailureIT { @Override protected void process(SearchSession session, Object entity) { session.indexingPlan().add( entity ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateIT.java index c24243191e1..353cc5ef02a 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateIT.java @@ -12,13 +12,10 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexer; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; -@RunWith(NestedRunner.class) -public class PojoIndexingAddOrUpdateIT { +class PojoIndexingAddOrUpdateIT { private static final PojoIndexingOperationScenario SCENARIO = new PojoIndexingOperationScenario( BackendIndexingOperation.ADD_OR_UPDATE ) { @@ -62,7 +59,7 @@ CompletionStage execute(SearchIndexer indexer, Object providedId, DocumentRou }; @Nested - public static class IndexerBaseIT extends AbstractPojoIndexerOperationBaseIT { + class IndexerBaseIT extends AbstractPojoIndexerOperationBaseIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -70,7 +67,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexerNullEntityIT extends AbstractPojoIndexerAddOrUpdateNullEntityIT { + class IndexerNullEntityIT extends AbstractPojoIndexerAddOrUpdateNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -78,7 +75,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexerIndexingProcessorFailureIT extends AbstractPojoIndexingProcessorFailureIT { + class IndexerIndexingProcessorFailureIT extends AbstractPojoIndexingProcessorFailureIT { @Override protected void process(SearchSession session, Object entity) { session.indexer().addOrUpdate( entity ); @@ -86,7 +83,7 @@ protected void process(SearchSession session, Object entity) { } @Nested - public static class IndexingPlanBaseIT extends AbstractPojoIndexingPlanOperationBaseIT { + class IndexingPlanBaseIT extends AbstractPojoIndexingPlanOperationBaseIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -94,7 +91,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { + class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -102,7 +99,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { + class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -110,7 +107,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanIndexingProcessorFailureIT extends AbstractPojoIndexingProcessorFailureIT { + class IndexingPlanIndexingProcessorFailureIT extends AbstractPojoIndexingProcessorFailureIT { @Override protected void process(SearchSession session, Object entity) { session.indexingPlan().addOrUpdate( entity ); @@ -119,7 +116,7 @@ protected void process(SearchSession session, Object entity) { } @Nested - public static class IndexingPlanReindexingResolutionFailureIT extends AbstractPojoReindexingResolutionFailureIT { + class IndexingPlanReindexingResolutionFailureIT extends AbstractPojoReindexingResolutionFailureIT { @Override protected void process(SearchSession session, Object entity) { session.indexingPlan().addOrUpdate( entity ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateOrDeleteEntityAbsentIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateOrDeleteEntityAbsentIT.java index 2ccf2ffbc06..9918c686534 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateOrDeleteEntityAbsentIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateOrDeleteEntityAbsentIT.java @@ -6,17 +6,13 @@ */ package org.hibernate.search.integrationtest.mapper.pojo.work.operations; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; - -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; /** * Test behavior of "addOrUpdateOrDelete" when the entity is absent upon loading, * this resulting in a "delete". */ -@RunWith(NestedRunner.class) -public class PojoIndexingAddOrUpdateOrDeleteEntityAbsentIT { +class PojoIndexingAddOrUpdateOrDeleteEntityAbsentIT { private static final PojoIndexingOperationScenario SCENARIO = new PojoIndexingAddOrUpdateOrDeleteScenario( BackendIndexingOperation.DELETE ) { @@ -27,7 +23,7 @@ public boolean isEntityPresentOnLoading() { }; @Nested - public static class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { + class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -35,7 +31,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { + class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateOrDeleteEntityPresentIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateOrDeleteEntityPresentIT.java index 17c14fee652..28f60c95b3b 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateOrDeleteEntityPresentIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingAddOrUpdateOrDeleteEntityPresentIT.java @@ -6,17 +6,13 @@ */ package org.hibernate.search.integrationtest.mapper.pojo.work.operations; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; - -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; /** * Test behavior of "addOrUpdateOrDelete" when the entity is present upon loading, * this resulting in a "addOrUpdate". */ -@RunWith(NestedRunner.class) -public class PojoIndexingAddOrUpdateOrDeleteEntityPresentIT { +class PojoIndexingAddOrUpdateOrDeleteEntityPresentIT { private static final PojoIndexingOperationScenario SCENARIO = new PojoIndexingAddOrUpdateOrDeleteScenario( BackendIndexingOperation.ADD_OR_UPDATE ) { @@ -27,7 +23,7 @@ boolean isEntityPresentOnLoading() { }; @Nested - public static class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { + class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -35,7 +31,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { + class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingDeleteIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingDeleteIT.java index e0170924ac5..66c6e329e4e 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingDeleteIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/work/operations/PojoIndexingDeleteIT.java @@ -12,13 +12,10 @@ import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexer; import org.hibernate.search.mapper.pojo.standalone.work.SearchIndexingPlan; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; -@RunWith(NestedRunner.class) -public class PojoIndexingDeleteIT { +class PojoIndexingDeleteIT { private static final PojoIndexingOperationScenario SCENARIO = new PojoIndexingOperationScenario( BackendIndexingOperation.DELETE ) { @@ -62,7 +59,7 @@ CompletionStage execute(SearchIndexer indexer, Object providedId, DocumentRou }; @Nested - public static class IndexerBaseIT extends AbstractPojoIndexerOperationBaseIT { + class IndexerBaseIT extends AbstractPojoIndexerOperationBaseIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -70,7 +67,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexerNullEntityIT extends AbstractPojoIndexerDeleteNullEntityIT { + class IndexerNullEntityIT extends AbstractPojoIndexerDeleteNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -78,7 +75,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanBaseIT extends AbstractPojoIndexingPlanOperationBaseIT { + class IndexingPlanBaseIT extends AbstractPojoIndexingPlanOperationBaseIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -86,7 +83,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { + class IndexingPlanNullEntityIT extends AbstractPojoIndexingPlanOperationNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -94,7 +91,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { + class IndexingPlanContainedNullEntityIT extends AbstractPojoIndexingPlanOperationContainedNullEntityIT { @Override protected PojoIndexingOperationScenario scenario() { return SCENARIO; @@ -102,7 +99,7 @@ protected PojoIndexingOperationScenario scenario() { } @Nested - public static class IndexingPlanReindexingResolutionFailureIT extends AbstractPojoReindexingResolutionFailureIT { + class IndexingPlanReindexingResolutionFailureIT extends AbstractPojoReindexingResolutionFailureIT { @Override protected void process(SearchSession session, Object entity) { session.indexingPlan().delete( entity ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/AbstractSearchWorkspaceSimpleOperationIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/AbstractSearchWorkspaceSimpleOperationIT.java index bc6d98bcfed..02730430c75 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/AbstractSearchWorkspaceSimpleOperationIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/AbstractSearchWorkspaceSimpleOperationIT.java @@ -20,24 +20,24 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.standalone.work.SearchWorkspace; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; public abstract class AbstractSearchWorkspaceSimpleOperationIT { private static final String BACKEND2_NAME = "stubBackend2"; - @Rule - public BackendMock defaultBackendMock = new BackendMock(); + @RegisterExtension + public BackendMock defaultBackendMock = BackendMock.create(); - @Rule - public BackendMock backend2Mock = new BackendMock(); + @RegisterExtension + public BackendMock backend2Mock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper; private SearchMapping mapping; @@ -49,8 +49,8 @@ public AbstractSearchWorkspaceSimpleOperationIT() { defaultBackendMock, namedBackendMocks ); } - @Before - public void setup() { + @BeforeEach + void setup() { defaultBackendMock.expectAnySchema( IndexedEntity1.INDEX_NAME ); backend2Mock.expectAnySchema( IndexedEntity2.INDEX_NAME ); @@ -59,7 +59,7 @@ public void setup() { } @Test - public void async_success() { + void async_success() { try ( SearchSession session = mapping.createSession() ) { SearchWorkspace workspace = session.workspace( IndexedEntity1.class ); @@ -76,7 +76,7 @@ public void async_success() { } @Test - public void async_failure() { + void async_failure() { try ( SearchSession session = mapping.createSession() ) { SearchWorkspace workspace = session.workspace( IndexedEntity1.class ); @@ -94,7 +94,7 @@ public void async_failure() { } @Test - public void sync_success() { + void sync_success() { try ( SearchSession session = mapping.createSession() ) { SearchWorkspace workspace = session.workspace( IndexedEntity1.class ); @@ -108,7 +108,7 @@ public void sync_success() { } @Test - public void sync_failure() { + void sync_failure() { try ( SearchSession session = mapping.createSession() ) { SearchWorkspace workspace = session.workspace( IndexedEntity1.class ); @@ -126,7 +126,7 @@ public void sync_failure() { } @Test - public void multiIndexMultiBackend() { + void multiIndexMultiBackend() { try ( SearchSession session = mapping.createSession() ) { SearchWorkspace workspace = session.workspace(); @@ -149,7 +149,7 @@ public void multiIndexMultiBackend() { } @Test - public void outOfSession() { + void outOfSession() { SearchWorkspace workspace; try ( SearchSession session = mapping.createSession() ) { workspace = session.workspace( IndexedEntity1.class ); @@ -167,7 +167,7 @@ public void outOfSession() { } @Test - public void fromMappingWithoutSession() { + void fromMappingWithoutSession() { SearchWorkspace workspace = mapping .scope( IndexedEntity1.class ).workspace(); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceFlushIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceFlushIT.java index d76ba568c0c..cb27682610a 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceFlushIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceFlushIT.java @@ -10,11 +10,11 @@ import java.util.concurrent.CompletionStage; import org.hibernate.search.mapper.pojo.standalone.work.SearchWorkspace; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-4621") -public class SearchWorkspaceFlushIT extends AbstractSearchWorkspaceSimpleOperationIT { +class SearchWorkspaceFlushIT extends AbstractSearchWorkspaceSimpleOperationIT { @Override protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture future) { backendMock.expectIndexScaleWorks( indexName ) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceMergeSegmentsIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceMergeSegmentsIT.java index 723cc16682e..115ab0274ca 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceMergeSegmentsIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceMergeSegmentsIT.java @@ -10,11 +10,11 @@ import java.util.concurrent.CompletionStage; import org.hibernate.search.mapper.pojo.standalone.work.SearchWorkspace; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-4621") -public class SearchWorkspaceMergeSegmentsIT extends AbstractSearchWorkspaceSimpleOperationIT { +class SearchWorkspaceMergeSegmentsIT extends AbstractSearchWorkspaceSimpleOperationIT { @Override protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture future) { backendMock.expectIndexScaleWorks( indexName ) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspacePurgeBaseIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspacePurgeBaseIT.java index b86e42a401e..36988d5e5bd 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspacePurgeBaseIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspacePurgeBaseIT.java @@ -10,11 +10,11 @@ import java.util.concurrent.CompletionStage; import org.hibernate.search.mapper.pojo.standalone.work.SearchWorkspace; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-4621") -public class SearchWorkspacePurgeBaseIT extends AbstractSearchWorkspaceSimpleOperationIT { +class SearchWorkspacePurgeBaseIT extends AbstractSearchWorkspaceSimpleOperationIT { @Override protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture future) { backendMock.expectIndexScaleWorks( indexName ) diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspacePurgeRoutingKeyIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspacePurgeRoutingKeyIT.java index 73b52ffd2ef..f2e6ad064ef 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspacePurgeRoutingKeyIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspacePurgeRoutingKeyIT.java @@ -12,11 +12,11 @@ import org.hibernate.search.mapper.pojo.standalone.work.SearchWorkspace; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-4621") -public class SearchWorkspacePurgeRoutingKeyIT extends AbstractSearchWorkspaceSimpleOperationIT { +class SearchWorkspacePurgeRoutingKeyIT extends AbstractSearchWorkspaceSimpleOperationIT { private final Set ROUTING_KEYS = CollectionHelper.asLinkedHashSet( "key1", "key2" ); diff --git a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceRefreshIT.java b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceRefreshIT.java index c75fe5d03c4..181aa70f625 100644 --- a/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceRefreshIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/workspace/SearchWorkspaceRefreshIT.java @@ -10,11 +10,11 @@ import java.util.concurrent.CompletionStage; import org.hibernate.search.mapper.pojo.standalone.work.SearchWorkspace; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; import org.hibernate.search.util.impl.test.annotation.TestForIssue; @TestForIssue(jiraKey = "HSEARCH-4621") -public class SearchWorkspaceRefreshIT extends AbstractSearchWorkspaceSimpleOperationIT { +class SearchWorkspaceRefreshIT extends AbstractSearchWorkspaceSimpleOperationIT { @Override protected void expectWork(BackendMock backendMock, String indexName, CompletableFuture future) { backendMock.expectIndexScaleWorks( indexName ) diff --git a/integrationtest/mapper/pojo-base/src/test/java17-noparameters/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/noparameters/ProjectionConstructorClassNoParametersCompilerFlagIT.java b/integrationtest/mapper/pojo-base/src/test/java17-noparameters/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/noparameters/ProjectionConstructorClassNoParametersCompilerFlagIT.java index f0a0afc8d84..85e454dbe08 100644 --- a/integrationtest/mapper/pojo-base/src/test/java17-noparameters/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/noparameters/ProjectionConstructorClassNoParametersCompilerFlagIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java17-noparameters/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/noparameters/ProjectionConstructorClassNoParametersCompilerFlagIT.java @@ -29,17 +29,18 @@ import org.hibernate.search.util.impl.integrationtest.common.reporting.FailureReportUtils; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProjectionConstructorClassNoParametersCompilerFlagIT extends AbstractProjectionConstructorIT { - @Rule +class ProjectionConstructorClassNoParametersCompilerFlagIT extends AbstractProjectionConstructorIT { + + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Before - public void sourcesCompiledWithoutParametersFlag() { + @BeforeEach + void sourcesCompiledWithoutParametersFlag() { assertThat( ConstructorWithParameters.class.getDeclaredConstructors()[0].getParameters() ) .withFailMessage( "This test only works if compiled *without* the '-parameters' compiler flag." ) .extracting( Parameter::isNamePresent ) @@ -47,7 +48,7 @@ public void sourcesCompiledWithoutParametersFlag() { } @Test - public void implicitInnerMapping() { + void implicitInnerMapping() { @ProjectionConstructor class MyProjection { private final String someText; @@ -97,7 +98,7 @@ static class InnerProjection { } @Test - public void explicitInnerMapping_implicitPath() { + void explicitInnerMapping_implicitPath() { @ProjectionConstructor class MyProjection { private final String someText; @@ -150,7 +151,7 @@ static class InnerProjection { } @Test - public void explicitInnerMapping_explicitPath() { + void explicitInnerMapping_explicitPath() { @ProjectionConstructor class MyProjection { private final String someText; diff --git a/integrationtest/mapper/pojo-base/src/test/java17-noparameters/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/noparameters/ProjectionConstructorRecordNoParametersCompilerFlagIT.java b/integrationtest/mapper/pojo-base/src/test/java17-noparameters/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/noparameters/ProjectionConstructorRecordNoParametersCompilerFlagIT.java index e3031be3386..6a1b0a5cf5c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java17-noparameters/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/noparameters/ProjectionConstructorRecordNoParametersCompilerFlagIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java17-noparameters/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/noparameters/ProjectionConstructorRecordNoParametersCompilerFlagIT.java @@ -19,19 +19,22 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ProjectionConstructor; import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; +import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProjectionConstructorRecordNoParametersCompilerFlagIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorRecordNoParametersCompilerFlagIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); - @Before - public void sourcesCompiledWithoutParametersFlag() { + @BeforeEach + void sourcesCompiledWithoutParametersFlag() { assertThat( ConstructorWithParameters.class.getDeclaredConstructors()[0].getParameters() ) .withFailMessage( "This test only works if compiled *without* the '-parameters' compiler flag." ) .extracting( Parameter::isNamePresent ) @@ -39,7 +42,7 @@ public void sourcesCompiledWithoutParametersFlag() { } @Test - public void typeLevelAnnotation() { + void typeLevelAnnotation() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -78,7 +81,7 @@ record MyProjection(String text, Integer integer) { } } @Test - public void constructorLevelAnnotation_canonical() { + void constructorLevelAnnotation_canonical() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java17/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorRecordIT.java b/integrationtest/mapper/pojo-base/src/test/java17/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorRecordIT.java index 1d2c05e7bc9..e0b066d0266 100644 --- a/integrationtest/mapper/pojo-base/src/test/java17/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorRecordIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java17/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/ProjectionConstructorRecordIT.java @@ -9,27 +9,30 @@ import java.lang.invoke.MethodHandles; import java.util.Arrays; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FieldProjection; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IdProjection; -import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FieldProjection; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IdProjection; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.ProjectionConstructor; +import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; +import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.common.extension.StubSearchWorkBehavior; +import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class ProjectionConstructorRecordIT extends AbstractProjectionConstructorIT { +class ProjectionConstructorRecordIT extends AbstractProjectionConstructorIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); @Test - public void typeLevelAnnotation() { + void typeLevelAnnotation() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -40,7 +43,8 @@ class IndexedEntity { public Integer integer; } @ProjectionConstructor - record MyProjection(String text, Integer integer) { } + record MyProjection(String text, Integer integer) { + } backendMock.expectAnySchema( INDEX_NAME ); SearchMapping mapping = setupHelper.start() @@ -69,7 +73,7 @@ record MyProjection(String text, Integer integer) { } @Test @TestForIssue(jiraKey = "HSEARCH-4853") - public void constructorLevelAnnotation_canonical() { + void constructorLevelAnnotation_canonical() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -115,7 +119,7 @@ public MyProjection(String text, Integer integer, String somethingElse) { } @Test - public void constructorLevelAnnotation_nonCanonical() { + void constructorLevelAnnotation_nonCanonical() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId @@ -164,7 +168,7 @@ public MyProjection(String text, Integer integer, String otherText) { } @Test - public void innerExplicit() { + void innerExplicit() { @Indexed(index = INDEX_NAME) class IndexedEntity { @DocumentId diff --git a/integrationtest/mapper/pojo-base/src/test/java17/org/hibernate/search/integrationtest/mapper/pojo/model/IndexedEmbeddedRecordIT.java b/integrationtest/mapper/pojo-base/src/test/java17/org/hibernate/search/integrationtest/mapper/pojo/model/IndexedEmbeddedRecordIT.java index 5fbcc5953a5..9e07e14d10c 100644 --- a/integrationtest/mapper/pojo-base/src/test/java17/org/hibernate/search/integrationtest/mapper/pojo/model/IndexedEmbeddedRecordIT.java +++ b/integrationtest/mapper/pojo-base/src/test/java17/org/hibernate/search/integrationtest/mapper/pojo/model/IndexedEmbeddedRecordIT.java @@ -10,35 +10,35 @@ import java.util.List; import org.hibernate.search.engine.backend.analysis.AnalyzerNames; -import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; -import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendMock; +import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; +import org.hibernate.search.mapper.pojo.standalone.session.SearchSession; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendMock; +import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class IndexedEmbeddedRecordIT { +class IndexedEmbeddedRecordIT { - @Rule - public BackendMock backendMock = new BackendMock(); + @RegisterExtension + public BackendMock backendMock = BackendMock.create(); - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withBackendMock( MethodHandles.lookup(), backendMock ); private SearchMapping mapping; - @Before - public void setup() { + @BeforeEach + void setup() { backendMock.expectSchema( IndexedEntity.INDEX, b -> b .objectField( "myRecord", b2 -> b2 .field( "text", String.class, b3 -> b3.analyzerName( AnalyzerNames.DEFAULT ) ) @@ -54,7 +54,7 @@ public void setup() { } @Test - public void index() { + void index() { try ( SearchSession session = mapping.createSession() ) { IndexedEntity entity1 = new IndexedEntity(); entity1.id = 1; diff --git a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/EntityAsGraphSmokeIT.java b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/EntityAsGraphSmokeIT.java index 64f4fa37fa3..79ec7485f44 100644 --- a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/EntityAsGraphSmokeIT.java +++ b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/EntityAsGraphSmokeIT.java @@ -29,9 +29,9 @@ import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Smoke test for the Standalone POJO mapper with a real backend @@ -41,9 +41,9 @@ * but it requires developers to explicitly provide association metadata * using {@link org.hibernate.search.mapper.pojo.mapping.definition.annotation.AssociationInverseSide}. */ -public class EntityAsGraphSmokeIT { +class EntityAsGraphSmokeIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withSingleBackend( MethodHandles.lookup(), BackendConfigurations.simple() ); @@ -52,8 +52,8 @@ public class EntityAsGraphSmokeIT { private final Map simulatedIndexedEntityDatastore = new HashMap<>(); - @Before - public void setup() { + @BeforeEach + void setup() { mapping = setupHelper.start() .withAnnotatedTypes( ContainedNonEntity.class, IndexedEntity.class, ContainedEntity.class ) .withConfiguration( b -> b @@ -65,7 +65,7 @@ public void setup() { } @Test - public void indexAndSearch() { + void indexAndSearch() { IndexedEntity indexed1 = new IndexedEntity( "1", "some interesting text" ); ContainedEntity containedEntity1_1 = new ContainedEntity( "1_1", "some contained entity text" ); containedEntity1_1.containing = indexed1; diff --git a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/EntityAsTreeSmokeIT.java b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/EntityAsTreeSmokeIT.java index 6cea1d1ed5d..9239544762b 100644 --- a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/EntityAsTreeSmokeIT.java +++ b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/EntityAsTreeSmokeIT.java @@ -27,9 +27,9 @@ import org.hibernate.search.mapper.pojo.work.IndexingPlanSynchronizationStrategy; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Smoke test for the Standalone POJO mapper with a real backend @@ -39,9 +39,9 @@ * but the main advantage is that associations are essentially ignored by Hibernate Search, * sparing developers from using {@link org.hibernate.search.mapper.pojo.mapping.definition.annotation.AssociationInverseSide}. */ -public class EntityAsTreeSmokeIT { +class EntityAsTreeSmokeIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withSingleBackend( MethodHandles.lookup(), BackendConfigurations.simple() ); @@ -50,8 +50,8 @@ public class EntityAsTreeSmokeIT { private final Map simulatedIndexedEntityDatastore = new HashMap<>(); - @Before - public void setup() { + @BeforeEach + void setup() { mapping = setupHelper.start() .withAnnotatedTypes( ContainedNonEntity.class, IndexedEntity.class, ContainedEntity.class ) .withConfiguration( b -> b @@ -64,7 +64,7 @@ public void setup() { } @Test - public void indexAndSearch() { + void indexAndSearch() { IndexedEntity indexed1 = new IndexedEntity( "1", "some interesting text" ); ContainedEntity containedEntity1_1 = new ContainedEntity( "1_1", "some contained entity text" ); containedEntity1_1.containing = indexed1; diff --git a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/mapping/DecimalScaleMappingIT.java b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/mapping/DecimalScaleMappingIT.java index 0c56679b673..b34b5558096 100644 --- a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/mapping/DecimalScaleMappingIT.java +++ b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/mapping/DecimalScaleMappingIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.mapper.pojo.standalone.realbackend.mapping; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.lang.invoke.MethodHandles; import java.math.BigInteger; @@ -17,17 +17,17 @@ import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; -public class DecimalScaleMappingIT { +class DecimalScaleMappingIT { - @Rule + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withSingleBackend( MethodHandles.lookup(), BackendConfigurations.simple() ); @Test - public void testFailingWithHint() { + void testFailingWithHint() { assertThatThrownBy( () -> setupHelper.start().setup( FailingEntity.class ) ).isInstanceOf( SearchException.class ) .hasMessageContainingAll( diff --git a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java index dbfd715e66a..aa45fa5f8d3 100644 --- a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java +++ b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/schema/management/ElasticsearchSchemaManagerExporterIT.java @@ -6,11 +6,11 @@ */ package org.hibernate.search.integrationtest.mapper.pojo.standalone.realbackend.schema.management; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect.isActualVersion; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEquals; import static org.hibernate.search.util.impl.test.JsonHelper.assertJsonEqualsIgnoringUnknownFields; -import static org.junit.Assume.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import java.io.IOException; import java.io.OutputStream; @@ -31,23 +31,23 @@ import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; -public class ElasticsearchSchemaManagerExporterIT { +class ElasticsearchSchemaManagerExporterIT { - @Rule - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); - @Rule + @TempDir + public Path temporaryFolder; + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withSingleBackend( MethodHandles.lookup(), BackendConfigurations.simple() ); private SearchMapping mapping; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { String version = ElasticsearchTestDialect.getActualVersion().toString(); this.mapping = setupHelper.start() // so that we don't try to do anything with the schema and allow to run without ES being up: @@ -64,16 +64,16 @@ public void setUp() throws Exception { } @Test - public void elasticsearch() throws IOException { + void elasticsearch() throws IOException { assumeFalse( - "Older versions of Elasticsearch would not match the mappings", isActualVersion( esVersion -> esVersion.isLessThan( "7.0" ), osVersion -> false - ) + ), + "Older versions of Elasticsearch would not match the mappings" ); - Path directory = temporaryFolder.newFolder().toPath(); + Path directory = temporaryFolder; mapping.scope( Object.class ).schemaManager().exportExpectedSchema( directory ); assertJsonEqualsIgnoringUnknownFields( @@ -161,8 +161,8 @@ public void elasticsearch() throws IOException { } @Test - public void exportToExistingDirectory() throws IOException { - Path directory = temporaryFolder.newFolder().toPath(); + void exportToExistingDirectory() throws IOException { + Path directory = temporaryFolder; Path path = Files.createDirectories( directory.resolve( "backend" ) .resolve( "indexes" ) .resolve( Book.NAME ) @@ -185,8 +185,8 @@ public void exportToExistingDirectory() throws IOException { } @Test - public void exportToExistingFile() throws IOException { - Path directory = temporaryFolder.newFolder().toPath(); + void exportToExistingFile() throws IOException { + Path directory = temporaryFolder; Path path = Files.createDirectories( directory.resolve( "backend" ) .resolve( "indexes" ) ); diff --git a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/schema/management/LuceneSchemaManagerExporterIT.java b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/schema/management/LuceneSchemaManagerExporterIT.java index cb96be9d82d..33f925189ac 100644 --- a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/schema/management/LuceneSchemaManagerExporterIT.java +++ b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/schema/management/LuceneSchemaManagerExporterIT.java @@ -22,28 +22,28 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.SearchMapping; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoMappingSetupHelper; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; -public class LuceneSchemaManagerExporterIT { +class LuceneSchemaManagerExporterIT { - @Rule - public final TemporaryFolder temporaryFolder = new TemporaryFolder(); - @Rule + @TempDir + public Path temporaryFolder; + @RegisterExtension public StandalonePojoMappingSetupHelper setupHelper = StandalonePojoMappingSetupHelper.withSingleBackend( MethodHandles.lookup(), BackendConfigurations.simple() ); @Test - public void lucene() throws IOException { + void lucene() throws IOException { SearchMapping mapping = setupHelper.start() .withProperty( "hibernate.search.backend.type", "lucene" ) .withProperty( "hibernate.search.backends." + Article.BACKEND_NAME + ".type", "lucene" ) .setup( Book.class, Article.class ); - Path directory = temporaryFolder.newFolder().toPath(); + Path directory = temporaryFolder; mapping.scope( Object.class ).schemaManager().exportExpectedSchema( directory ); String bookIndex = readString( diff --git a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/testsupport/BackendConfigurations.java b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/testsupport/BackendConfigurations.java index bb35540422c..36d743e93d8 100644 --- a/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/testsupport/BackendConfigurations.java +++ b/integrationtest/mapper/pojo-standalone-realbackend/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/standalone/realbackend/testsupport/BackendConfigurations.java @@ -6,11 +6,11 @@ */ package org.hibernate.search.integrationtest.mapper.pojo.standalone.realbackend.testsupport; -import static org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration.BACKEND_TYPE; +import static org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration.BACKEND_TYPE; import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchBackendConfiguration; import org.hibernate.search.util.impl.integrationtest.backend.lucene.LuceneBackendConfiguration; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendConfiguration; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendConfiguration; public class BackendConfigurations { diff --git a/integrationtest/performance/backend/base/src/test/java/org/hibernate/search/integrationtest/performance/backend/base/testsupport/dataset/SimpleDataSampleParserTest.java b/integrationtest/performance/backend/base/src/test/java/org/hibernate/search/integrationtest/performance/backend/base/testsupport/dataset/SimpleDataSampleParserTest.java index 804c57800fa..de2fcffda6f 100644 --- a/integrationtest/performance/backend/base/src/test/java/org/hibernate/search/integrationtest/performance/backend/base/testsupport/dataset/SimpleDataSampleParserTest.java +++ b/integrationtest/performance/backend/base/src/test/java/org/hibernate/search/integrationtest/performance/backend/base/testsupport/dataset/SimpleDataSampleParserTest.java @@ -13,15 +13,15 @@ import org.hibernate.search.util.common.annotation.impl.SuppressJQAssistant; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.google.common.io.CharSource; @SuppressJQAssistant(reason = "This really is a unit test, not an IT, so we want the 'Test' suffix") -public class SimpleDataSampleParserTest { +class SimpleDataSampleParserTest { @Test - public void test() throws IOException { + void test() throws IOException { List samples = CharSource.wrap( "\n" + "This is the first real line\n" + "Followed by another one\n" diff --git a/integrationtest/performance/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/performance/backend/elasticsearch/SmokeIT.java b/integrationtest/performance/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/performance/backend/elasticsearch/SmokeIT.java index 73e63a4c286..e28ff8a1ca5 100644 --- a/integrationtest/performance/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/performance/backend/elasticsearch/SmokeIT.java +++ b/integrationtest/performance/backend/elasticsearch/src/test/java/org/hibernate/search/integrationtest/performance/backend/elasticsearch/SmokeIT.java @@ -15,9 +15,9 @@ import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.ElasticsearchTestHostConnectionConfiguration; import org.hibernate.search.util.impl.test.SystemHelper; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; @@ -32,11 +32,11 @@ *

* See README to know how to run the benchmark from the command line to obtain more reliable results. */ -public class SmokeIT { +class SmokeIT { private final List toClose = new ArrayList<>(); - @Before - public void setupConnectionInfo() { + @BeforeEach + void setupConnectionInfo() { Map connectionInfo = new LinkedHashMap<>(); ElasticsearchTestHostConnectionConfiguration.get().addToBackendProperties( connectionInfo ); connectionInfo.forEach( (key, value) -> { @@ -46,15 +46,15 @@ public void setupConnectionInfo() { } ); } - @After - public void restoreSystemProperties() { + @AfterEach + void restoreSystemProperties() { try ( Closer closer = new Closer<>() ) { closer.pushAll( SystemHelper.SystemPropertyRestorer::close, toClose ); } } @Test - public void test() throws RunnerException { + void test() throws RunnerException { Options opts = new OptionsBuilder() .include( ".*" ) .warmupIterations( 0 ) diff --git a/integrationtest/performance/backend/lucene/src/test/java/org/hibernate/search/integrationtest/performance/backend/lucene/SmokeIT.java b/integrationtest/performance/backend/lucene/src/test/java/org/hibernate/search/integrationtest/performance/backend/lucene/SmokeIT.java index 56e16595858..768fcd0de74 100644 --- a/integrationtest/performance/backend/lucene/src/test/java/org/hibernate/search/integrationtest/performance/backend/lucene/SmokeIT.java +++ b/integrationtest/performance/backend/lucene/src/test/java/org/hibernate/search/integrationtest/performance/backend/lucene/SmokeIT.java @@ -6,7 +6,7 @@ */ package org.hibernate.search.integrationtest.performance.backend.lucene; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; @@ -21,10 +21,10 @@ *

* See README to know how to run the benchmark from the command line to obtain more reliable results. */ -public class SmokeIT { +class SmokeIT { @Test - public void test() throws RunnerException { + void test() throws RunnerException { Options opts = new OptionsBuilder() .include( ".*" ) .warmupIterations( 0 ) diff --git a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseMassIndexingIT.java b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseMassIndexingIT.java index 21bc2776740..a1801f14bd2 100644 --- a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseMassIndexingIT.java +++ b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseMassIndexingIT.java @@ -14,24 +14,21 @@ import org.hibernate.search.integrationtest.showcase.library.service.TestDataService; import org.hibernate.search.mapper.orm.massindexing.MassIndexer; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) @SpringBootTest @TestPropertySource(properties = { "spring.jpa.properties.hibernate.search.indexing.listeners.enabled=false" }) @ActiveProfiles(resolver = TestActiveProfilesResolver.class) -public class LibraryShowcaseMassIndexingIT { +class LibraryShowcaseMassIndexingIT { private static final int NUMBER_OF_BOOKS = 200; @@ -44,13 +41,13 @@ public class LibraryShowcaseMassIndexingIT { @Autowired private TestDataService testDataService; - @Before - public void initData() { + @BeforeEach + void initData() { testDataService.initBooksDataSet( NUMBER_OF_BOOKS ); } - @After - public void cleanUpData() { + @AfterEach + void cleanUpData() { // we're cleaning the data manually, // in order to have a class level application context, // to support the job of ExpectedLog4jLog @@ -58,7 +55,7 @@ public void cleanUpData() { } @Test - public void testMassIndexing() { + void testMassIndexing() { assertThat( documentService.countIndexed() ).isZero(); MassIndexer indexer = adminService.createMassIndexer(); try { diff --git a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseSearchIT.java b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseSearchIT.java index cae9d685215..65139a73ae5 100644 --- a/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseSearchIT.java +++ b/integrationtest/showcase/library/src/test/java/org/hibernate/search/integrationtest/showcase/library/LibraryShowcaseSearchIT.java @@ -29,8 +29,6 @@ import static org.hibernate.search.integrationtest.showcase.library.service.TestDataService.SUBURBAN_2_ID; import static org.hibernate.search.integrationtest.showcase.library.service.TestDataService.THESAURUS_OF_LANGUAGES_ID; import static org.hibernate.search.integrationtest.showcase.library.service.TestDataService.UNIVERSITY_ID; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Collections; @@ -55,22 +53,19 @@ import org.hibernate.search.integrationtest.showcase.library.service.TestDataService; import org.hibernate.search.util.common.data.Range; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) @SpringBootTest @ActiveProfiles(resolver = TestActiveProfilesResolver.class) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) -public class LibraryShowcaseSearchIT { +class LibraryShowcaseSearchIT { private static boolean needsInit; @@ -86,13 +81,13 @@ public class LibraryShowcaseSearchIT { @Autowired private TestDataService testDataService; - @BeforeClass - public static void beforeClass() { + @BeforeAll + static void beforeClass() { needsInit = true; } - @Before - public void before() { + @BeforeEach + void before() { if ( needsInit ) { testDataService.initDefaultDataSet(); needsInit = false; @@ -100,7 +95,7 @@ public void before() { } @Test - public void search_library() { + void search_library() { List libraries = libraryService.search( "library", 0, 10 ); assertThat( libraries ).extracting( Library::getId ).containsExactly( CITY_CENTER_ID, @@ -130,7 +125,7 @@ public void search_library() { } @Test - public void search_person() { + void search_person() { List results = borrowalService.searchPerson( "smith", 0, 10 ); @@ -170,22 +165,28 @@ public void search_person() { } @Test - public void search_single() { + void search_single() { Optional book = documentService.getByIsbn( "978-0-00-000001-1" ); - assertTrue( book.isPresent() ); - assertThat( book.get().getId() ).isEqualTo( CALLIGRAPHY_ID ); + assertThat( book ).isPresent() + .get() + .extracting( Document::getId ) + .isEqualTo( CALLIGRAPHY_ID ); book = documentService.getByIsbn( "978-0-00-000005-5" ); - assertTrue( book.isPresent() ); - assertThat( book.get().getId() ).isEqualTo( ART_OF_COMPUTER_PROG_ID ); + assertThat( book ).isPresent() + .get() + .extracting( Document::getId ) + .isEqualTo( ART_OF_COMPUTER_PROG_ID ); book = documentService.getByIsbn( "978-0-00-000005-1" ); - assertFalse( book.isPresent() ); + assertThat( book ).isNotPresent(); // Test the normalizer book = documentService.getByIsbn( "9780000000055" ); - assertTrue( book.isPresent() ); - assertThat( book.get().getId() ).isEqualTo( ART_OF_COMPUTER_PROG_ID ); + assertThat( book ).isPresent() + .get() + .extracting( Document::getId ) + .isEqualTo( ART_OF_COMPUTER_PROG_ID ); } /** @@ -194,7 +195,7 @@ public void search_single() { * was successfully resolved to {@code List}. */ @Test - public void searchByMedium() { + void searchByMedium() { List books = documentService.searchByMedium( "java", BookMedium.DEMATERIALIZED, 0, 10 ); @@ -212,7 +213,7 @@ public void searchByMedium() { } @Test - public void searchAroundMe_spatial() { + void searchAroundMe_spatial() { GeoPoint myLocation = GeoPoint.of( 42.0, 0.5 ); List> documents = documentService.searchAroundMe( @@ -280,7 +281,7 @@ public void searchAroundMe_spatial() { } @Test - public void searchAroundMe_nested() { + void searchAroundMe_nested() { List> documents = documentService.searchAroundMe( "java", null, null, null, @@ -323,7 +324,7 @@ public void searchAroundMe_nested() { } @Test - public void searchAroundMe_searchBridge() { + void searchAroundMe_searchBridge() { List> documents = documentService.searchAroundMe( null, "java", null, null, @@ -365,7 +366,7 @@ public void searchAroundMe_searchBridge() { * and how this indexed data can then be queried. */ @Test - public void listTopBorrowers() { + void listTopBorrowers() { List results = borrowalService.listTopBorrowers( 0, 3 ); assertThat( results ).extracting( Person::getId ).containsExactly( JANE_SMITH_ID, @@ -392,7 +393,7 @@ public void listTopBorrowers() { * This demonstrates how to define a projection for the query and how to set order. */ @Test - public void projectionAndOrder() { + void projectionAndOrder() { List results = documentService.getAuthorsOfBooksHavingTerms( "java", SortOrder.ASC ); assertThat( results ).containsExactly( "Mark Red", "Michele Violet", "Stuart Green" ); @@ -401,7 +402,7 @@ public void projectionAndOrder() { } @Test - public void searchAndProject() { + void searchAndProject() { List libraries = libraryService.searchAndProject( "library", 0, 10 ); assertThat( libraries ).extracting( l -> l.name ).containsExactly( libraryService.getById( CITY_CENTER_ID, Library::getName ), @@ -433,7 +434,7 @@ public void searchAndProject() { // This checks that method-local classes get automatically indexed by Hibernate Search with Jandex, in particular. @Test - public void searchAndProjectToMethodLocalClass() { + void searchAndProjectToMethodLocalClass() { List libraries = libraryService.searchAndProjectToMethodLocalClass( "library", 0, 10 ); assertThat( libraries ).extracting( l -> l.name ).containsExactly( libraryService.getById( CITY_CENTER_ID, Library::getName ), @@ -464,7 +465,7 @@ public void searchAndProjectToMethodLocalClass() { } @Test - public void searchFaceted() { + void searchFaceted() { LibraryFacetedSearchResult result = libraryService.searchFaceted( null, null, null, 0, 10 diff --git a/integrationtest/showcase/library/src/test/java17/org/hibernate/search/integrationtest/showcase/library/Java17IT.java b/integrationtest/showcase/library/src/test/java17/org/hibernate/search/integrationtest/showcase/library/Java17IT.java index b6493486305..d801f9d55f5 100644 --- a/integrationtest/showcase/library/src/test/java17/org/hibernate/search/integrationtest/showcase/library/Java17IT.java +++ b/integrationtest/showcase/library/src/test/java17/org/hibernate/search/integrationtest/showcase/library/Java17IT.java @@ -20,22 +20,19 @@ import org.hibernate.search.integrationtest.showcase.library.service.LibraryService; import org.hibernate.search.integrationtest.showcase.library.service.TestDataService; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) @SpringBootTest @ActiveProfiles(resolver = TestActiveProfilesResolver.class) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) -public class Java17IT { +class Java17IT { private static boolean needsInit; @@ -48,13 +45,13 @@ public class Java17IT { @Autowired private TestDataService testDataService; - @BeforeClass - public static void beforeClass() { + @BeforeAll + static void beforeClass() { needsInit = true; } - @Before - public void before() { + @BeforeEach + void before() { if ( needsInit ) { testDataService.initDefaultDataSet(); needsInit = false; @@ -63,7 +60,7 @@ public void before() { // This checks that top-level records get automatically indexed by Hibernate Search with Jandex, in particular. @Test - public void searchAndProject() { + void searchAndProject() { List libraries = java17Service.searchAndProjectToRecord( "library", 0, 10 ); assertThat( libraries ).extracting( LibrarySimpleProjectionRecord::name ).containsExactly( libraryService.getById( CITY_CENTER_ID, Library::getName ), @@ -95,7 +92,7 @@ public void searchAndProject() { // This checks that method-local records get automatically indexed by Hibernate Search with Jandex, in particular. @Test - public void searchAndProjectToMethodLocalClass() { + void searchAndProjectToMethodLocalClass() { List libraries = java17Service.searchAndProjectToMethodLocalRecord( "library", 0, 10 ); assertThat( libraries ).extracting( LibrarySimpleProjectionRecord::name ).containsExactly( libraryService.getById( CITY_CENTER_ID, Library::getName ), diff --git a/integrationtest/v5migrationhelper/engine/pom.xml b/integrationtest/v5migrationhelper/engine/pom.xml index fb440121b3e..b9b96f25996 100755 --- a/integrationtest/v5migrationhelper/engine/pom.xml +++ b/integrationtest/v5migrationhelper/engine/pom.xml @@ -61,6 +61,17 @@ org.apache.maven.plugins maven-surefire-plugin + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + @@ -70,6 +81,17 @@ org.apache.maven.plugins maven-failsafe-plugin + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + it diff --git a/integrationtest/v5migrationhelper/engine/src/test/java/org/hibernate/search/testsupport/junit/SearchFactoryHolder.java b/integrationtest/v5migrationhelper/engine/src/test/java/org/hibernate/search/testsupport/junit/SearchFactoryHolder.java index 5a48ba66eae..e3624896ef7 100644 --- a/integrationtest/v5migrationhelper/engine/src/test/java/org/hibernate/search/testsupport/junit/SearchFactoryHolder.java +++ b/integrationtest/v5migrationhelper/engine/src/test/java/org/hibernate/search/testsupport/junit/SearchFactoryHolder.java @@ -6,6 +6,7 @@ */ package org.hibernate.search.testsupport.junit; +import static org.hibernate.search.test.util.impl.JunitJupiterContextHelper.extensionContext; import static org.junit.Assert.assertNull; import java.util.HashMap; @@ -15,6 +16,7 @@ import org.hibernate.search.spi.SearchIntegrator; import org.hibernate.search.testsupport.migration.V5MigrationStandalonePojoSearchIntegratorAdapter; +import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; @@ -52,9 +54,12 @@ public SearchMapping getMapping() { @Override public Statement apply(Statement base, Description description) { - Statement wrapped = new Statement() { + Statement statement = new Statement() { + @Override public void evaluate() throws Throwable { + ExtensionContext context = extensionContext( description ); + setupHelper.beforeAll( context ); try { mapping = setupHelper.start() .withProperties( configuration ) @@ -65,10 +70,11 @@ public void evaluate() throws Throwable { finally { mapping = null; searchIntegrator = null; + setupHelper.afterAll( context ); } } }; - return setupHelper.apply( wrapped, description ); + return statement; } public SearchFactoryHolder withProperty(String key, Object value) { diff --git a/integrationtest/v5migrationhelper/engine/src/test/java/org/hibernate/search/testsupport/junit/V5MigrationHelperEngineSetupHelper.java b/integrationtest/v5migrationhelper/engine/src/test/java/org/hibernate/search/testsupport/junit/V5MigrationHelperEngineSetupHelper.java index 03c0b48c5d3..b5444ad40f3 100644 --- a/integrationtest/v5migrationhelper/engine/src/test/java/org/hibernate/search/testsupport/junit/V5MigrationHelperEngineSetupHelper.java +++ b/integrationtest/v5migrationhelper/engine/src/test/java/org/hibernate/search/testsupport/junit/V5MigrationHelperEngineSetupHelper.java @@ -21,8 +21,8 @@ import org.hibernate.search.mapper.pojo.standalone.mapping.StandalonePojoMappingConfigurer; import org.hibernate.search.testsupport.configuration.V5MigrationHelperTestLuceneBackendConfiguration; import org.hibernate.search.util.common.impl.CollectionHelper; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendSetupStrategy; -import org.hibernate.search.util.impl.integrationtest.common.rule.MappingSetupHelper; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendSetupStrategy; +import org.hibernate.search.util.impl.integrationtest.common.extension.MappingSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.pojo.standalone.StandalonePojoAssertionHelper; @@ -42,7 +42,7 @@ public static V5MigrationHelperEngineSetupHelper create() { private final StandalonePojoAssertionHelper assertionHelper; private V5MigrationHelperEngineSetupHelper(BackendSetupStrategy backendSetupStrategy) { - super( backendSetupStrategy ); + super( backendSetupStrategy, Type.METHOD ); this.assertionHelper = new StandalonePojoAssertionHelper( backendSetupStrategy ); } diff --git a/integrationtest/v5migrationhelper/orm/pom.xml b/integrationtest/v5migrationhelper/orm/pom.xml index 4eb01e58a9b..d9e7baf1cfa 100755 --- a/integrationtest/v5migrationhelper/orm/pom.xml +++ b/integrationtest/v5migrationhelper/orm/pom.xml @@ -72,6 +72,17 @@ org.apache.maven.plugins maven-surefire-plugin + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + @@ -81,6 +92,17 @@ org.apache.maven.plugins maven-failsafe-plugin + + + + org.apache.maven.surefire + surefire-junit47 + ${version.surefire.plugin} + + it diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/facet/Fruit.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/facet/Fruit.java index 125b3fecea2..960970dc22e 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/facet/Fruit.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/facet/Fruit.java @@ -21,7 +21,7 @@ */ @Entity @Indexed -public class Fruit { +class Fruit { @Id @GeneratedValue private int id; diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/Kernel.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/Kernel.java index 21a82612425..21107ae5d5a 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/Kernel.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/Kernel.java @@ -16,7 +16,7 @@ import org.hibernate.search.annotations.DocumentId; import org.hibernate.search.annotations.Field; import org.hibernate.search.mapper.pojo.bridge.mapping.annotation.RoutingBinderRef; -import org.hibernate.search.util.impl.integrationtest.mapper.orm.StaticIndexingSwitch; +import org.hibernate.search.test.testsupport.StaticIndexingSwitch; /** * @author Emmanuel Bernard diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/SecondLCAndPCLookupTest.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/SecondLCAndPCLookupTest.java index a043991c95b..957f7c4f3d2 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/SecondLCAndPCLookupTest.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/SecondLCAndPCLookupTest.java @@ -22,7 +22,7 @@ import org.hibernate.search.query.ObjectLookupMethod; import org.hibernate.search.query.dsl.QueryBuilder; import org.hibernate.search.test.SearchTestBase; -import org.hibernate.search.util.impl.integrationtest.mapper.orm.StaticIndexingSwitch; +import org.hibernate.search.test.testsupport.StaticIndexingSwitch; import org.hibernate.stat.Statistics; import org.hibernate.testing.cache.CachingRegionFactory; diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/StrictKernel.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/StrictKernel.java index a2cb7f3dea1..53007111796 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/StrictKernel.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/StrictKernel.java @@ -16,7 +16,7 @@ import org.hibernate.search.annotations.DocumentId; import org.hibernate.search.annotations.Field; import org.hibernate.search.mapper.pojo.bridge.mapping.annotation.RoutingBinderRef; -import org.hibernate.search.util.impl.integrationtest.mapper.orm.StaticIndexingSwitch; +import org.hibernate.search.test.testsupport.StaticIndexingSwitch; /** * @author Emmanuel Bernard diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/StrictSecondLCAndPCLookupTest.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/StrictSecondLCAndPCLookupTest.java index 35da7fc0370..62620fbe050 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/StrictSecondLCAndPCLookupTest.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/query/initandlookup/StrictSecondLCAndPCLookupTest.java @@ -21,7 +21,7 @@ import org.hibernate.search.query.DatabaseRetrievalMethod; import org.hibernate.search.query.ObjectLookupMethod; import org.hibernate.search.test.SearchTestBase; -import org.hibernate.search.util.impl.integrationtest.mapper.orm.StaticIndexingSwitch; +import org.hibernate.search.test.testsupport.StaticIndexingSwitch; import org.hibernate.stat.Statistics; import org.hibernate.testing.cache.CachingRegionFactory; diff --git a/util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm/StaticIndexingSwitch.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/StaticIndexingSwitch.java similarity index 97% rename from util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm/StaticIndexingSwitch.java rename to integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/StaticIndexingSwitch.java index 66139ebd72c..bd1a247c4e4 100644 --- a/util/internal/integrationtest/mapper/orm/src/main/java/org/hibernate/search/util/impl/integrationtest/mapper/orm/StaticIndexingSwitch.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/StaticIndexingSwitch.java @@ -4,7 +4,7 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or . */ -package org.hibernate.search.util.impl.integrationtest.mapper.orm; +package org.hibernate.search.test.testsupport; import org.hibernate.search.mapper.pojo.bridge.RoutingBridge; import org.hibernate.search.mapper.pojo.bridge.binding.RoutingBindingContext; diff --git a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperJPASetupHelper.java b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperJPASetupHelper.java index 5c3d6d75447..d0c522218e2 100644 --- a/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperJPASetupHelper.java +++ b/integrationtest/v5migrationhelper/orm/src/test/java/org/hibernate/search/test/testsupport/V5MigrationHelperJPASetupHelper.java @@ -6,6 +6,8 @@ */ package org.hibernate.search.test.testsupport; +import static org.hibernate.search.test.util.impl.JunitJupiterContextHelper.extensionContext; + import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -20,19 +22,25 @@ import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; import org.hibernate.search.testsupport.TestConstants; import org.hibernate.search.testsupport.configuration.V5MigrationHelperTestLuceneBackendConfiguration; -import org.hibernate.search.util.impl.integrationtest.common.rule.BackendSetupStrategy; -import org.hibernate.search.util.impl.integrationtest.common.rule.MappingSetupHelper; +import org.hibernate.search.util.impl.integrationtest.common.extension.BackendSetupStrategy; +import org.hibernate.search.util.impl.integrationtest.common.extension.MappingSetupHelper; import org.hibernate.search.util.impl.integrationtest.common.stub.backend.BackendMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.HibernateOrmMappingHandle; import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmAssertionHelper; import org.hibernate.search.util.impl.integrationtest.mapper.orm.SimpleEntityManagerFactoryBuilder; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + public final class V5MigrationHelperJPASetupHelper extends MappingSetupHelper { + EntityManagerFactory> + implements TestRule { public static V5MigrationHelperJPASetupHelper create() { return new V5MigrationHelperJPASetupHelper( @@ -43,7 +51,7 @@ public static V5MigrationHelperJPASetupHelper create() { private final OrmAssertionHelper assertionHelper; private V5MigrationHelperJPASetupHelper(BackendSetupStrategy backendSetupStrategy) { - super( backendSetupStrategy ); + super( backendSetupStrategy, Type.METHOD ); this.assertionHelper = new OrmAssertionHelper( backendSetupStrategy ); } @@ -62,6 +70,23 @@ protected void close(EntityManagerFactory toClose) { toClose.close(); } + @Override + public Statement apply(Statement base, Description description) { + ExtensionContext context = extensionContext( description ); + return new Statement() { + @Override + public void evaluate() throws Throwable { + beforeAll( context ); + try { + base.evaluate(); + } + finally { + afterAll( context ); + } + } + }; + } + public final class SetupContext extends MappingSetupHelper { + SessionFactory> + implements TestRule { public static V5MigrationHelperOrmSetupHelper create() { return new V5MigrationHelperOrmSetupHelper( @@ -44,7 +52,7 @@ public static V5MigrationHelperOrmSetupHelper create() { private final OrmAssertionHelper assertionHelper; private V5MigrationHelperOrmSetupHelper(BackendSetupStrategy backendSetupStrategy) { - super( backendSetupStrategy ); + super( backendSetupStrategy, Type.METHOD ); this.assertionHelper = new OrmAssertionHelper( backendSetupStrategy ); } @@ -63,6 +71,23 @@ protected void close(SessionFactory toClose) { toClose.close(); } + @Override + public Statement apply(Statement base, Description description) { + ExtensionContext context = extensionContext( description ); + return new Statement() { + @Override + public void evaluate() throws Throwable { + beforeAll( context ); + try { + base.evaluate(); + } + finally { + afterAll( context ); + } + } + }; + } + public final class SetupContext extends MappingSetupHelper repositoryMockHelper.allAgentsInIdOrder() ); when( clockMock.instant() ).thenReturn( NOW ); } @Test - public void noOtherAgent() { + void noOtherAgent() { repositoryMockHelper.defineOtherAgents(); onNoOtherAgents().verify( link.pulse( contextMock ) ); } @Test - public void clusterWith4Nodes_someExpired() { + void clusterWith4Nodes_someExpired() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -201,7 +201,7 @@ public void clusterWith4Nodes_someExpired() { } @Test - public void clusterWith4Nodes_someSuspended_someWaiting() { + void clusterWith4Nodes_someSuspended_someWaiting() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.WAITING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -214,7 +214,7 @@ public void clusterWith4Nodes_someSuspended_someWaiting() { } @Test - public void clusterWith4Nodes_someSuspended_someRunning() { + void clusterWith4Nodes_someSuspended_someRunning() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -227,7 +227,7 @@ public void clusterWith4Nodes_someSuspended_someRunning() { } @Test - public void clusterWith4Nodes_someWaiting_someRunning() { + void clusterWith4Nodes_someWaiting_someRunning() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.WAITING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -240,7 +240,7 @@ public void clusterWith4Nodes_someWaiting_someRunning() { } @Test - public void clusterWith4Nodes_someSuspended_someWaiting_someRunning() { + void clusterWith4Nodes_someSuspended_someWaiting_someRunning() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.SUSPENDED, isOther1Static() ? otherShardAssignmentIn4NodeCluster( 1 ) : null ) @@ -253,7 +253,7 @@ public void clusterWith4Nodes_someSuspended_someWaiting_someRunning() { } @Test - public void clusterWith4Nodes_allSuspended() { + void clusterWith4Nodes_allSuspended() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.SUSPENDED, isOther1Static() ? otherShardAssignmentIn4NodeCluster( 1 ) : null ) @@ -266,7 +266,7 @@ public void clusterWith4Nodes_allSuspended() { } @Test - public void clusterWith4Nodes_allWaiting() { + void clusterWith4Nodes_allWaiting() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.WAITING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -279,7 +279,7 @@ public void clusterWith4Nodes_allWaiting() { } @Test - public void clusterWith4Nodes_allRunning() { + void clusterWith4Nodes_allRunning() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -292,7 +292,7 @@ public void clusterWith4Nodes_allRunning() { } @Test - public void clusterWith4Nodes_someExpired_massIndexingAgent_running() { + void clusterWith4Nodes_someExpired_massIndexingAgent_running() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -312,7 +312,7 @@ public void clusterWith4Nodes_someExpired_massIndexingAgent_running() { } @Test - public void clusterWith4Nodes_someSuspended_someRunning_massIndexingAgent_running() { + void clusterWith4Nodes_someSuspended_someRunning_massIndexingAgent_running() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -328,7 +328,7 @@ public void clusterWith4Nodes_someSuspended_someRunning_massIndexingAgent_runnin } @Test - public void clusterWith4Nodes_allRunning_massIndexingAgent_running() { + void clusterWith4Nodes_allRunning_massIndexingAgent_running() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -342,7 +342,7 @@ public void clusterWith4Nodes_allRunning_massIndexingAgent_running() { } @Test - public void clusterWith4Nodes_allRunning_massIndexingAgent_suspended() { + void clusterWith4Nodes_allRunning_massIndexingAgent_suspended() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -359,7 +359,7 @@ public void clusterWith4Nodes_allRunning_massIndexingAgent_suspended() { } @Test - public void clusterWith4Nodes_allRunning_massIndexingAgent_waiting() { + void clusterWith4Nodes_allRunning_massIndexingAgent_waiting() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -376,7 +376,7 @@ public void clusterWith4Nodes_allRunning_massIndexingAgent_waiting() { } @Test - public void clusterWith4Nodes_allRunning_massIndexingAgent_expired() { + void clusterWith4Nodes_allRunning_massIndexingAgent_expired() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), other1Type(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractEventProcessorClusterLinkTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractEventProcessorClusterLinkTest.java index 4b887e034e9..08f0fc30d65 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractEventProcessorClusterLinkTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractEventProcessorClusterLinkTest.java @@ -31,15 +31,17 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.ShardAssignmentDescriptor; import org.hibernate.search.util.common.spi.ToStringTreeAppender; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) abstract class AbstractEventProcessorClusterLinkTest { static final Instant NOW = Instant.parse( "2021-10-21T14:30:00.000Z" ); @@ -58,9 +60,6 @@ abstract class AbstractEventProcessorClusterLinkTest { static final UUID SELF_ID = toUUID( SELF_ID_ORDINAL ); static final AgentReference SELF_REF = AgentReference.of( SELF_ID, "Self Agent Name" ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock public FailureHandler failureHandlerMock; @@ -93,8 +92,8 @@ public void appendTo(ToStringTreeAppender appender) { protected AgentRepositoryMockingHelper repositoryMockHelper; - @Before - public final void initMocks() { + @BeforeEach + final void initMocks() { repositoryMockHelper = new AgentRepositoryMockingHelper( repositoryMock ); Collections.addAll( allMocks, failureHandlerMock, clockMock, eventFinderMock, repositoryMock ); @@ -103,8 +102,8 @@ public final void initMocks() { doNothing().when( contextMock ).commitAndBeginNewTransaction(); } - @After - public void verifyNoMoreInvocationsOnAllMocks() { + @AfterEach + void verifyNoMoreInvocationsOnAllMocks() { verifyNoMoreInteractions( allMocks.toArray() ); } diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractMassIndexerAgentClusterLinkBaseTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractMassIndexerAgentClusterLinkBaseTest.java index 9018406d889..47861be25e1 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractMassIndexerAgentClusterLinkBaseTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractMassIndexerAgentClusterLinkBaseTest.java @@ -17,8 +17,8 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentType; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.ShardAssignmentDescriptor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * This abstract class implements one test method for each "external" situation that @@ -40,8 +40,8 @@ abstract class AbstractMassIndexerAgentClusterLinkBaseTest extends AbstractMassI OutboxPollingMassIndexerAgentClusterLink link; - @Before - public final void initLink() { + @BeforeEach + final void initLink() { link = new OutboxPollingMassIndexerAgentClusterLink( SELF_REF.name, failureHandlerMock, clockMock, POLLING_INTERVAL, PULSE_INTERVAL, PULSE_EXPIRATION @@ -120,21 +120,21 @@ protected final ShardAssignmentDescriptor otherShardAssignmentIn4NodeCluster(int protected abstract MassIndexerAgentClusterLinkPulseExpectations onClusterWith3NodesAll3NodesSuspended(); - @Before - public void initPulseMocks() { + @BeforeEach + void initPulseMocks() { when( repositoryMock.findAllOrderById() ).thenAnswer( ignored -> repositoryMockHelper.allAgentsInIdOrder() ); when( clockMock.instant() ).thenReturn( NOW ); } @Test - public void noOtherAgent() { + void noOtherAgent() { repositoryMockHelper.defineOtherAgents(); onNoOtherAgents().verify( link.pulse( contextMock ) ); } @Test - public void clusterWith3Nodes_someExpired() { + void clusterWith3Nodes_someExpired() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -152,7 +152,7 @@ public void clusterWith3Nodes_someExpired() { } @Test - public void clusterWith3Nodes_someSuspended_someWaiting() { + void clusterWith3Nodes_someSuspended_someWaiting() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.WAITING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -165,7 +165,7 @@ public void clusterWith3Nodes_someSuspended_someWaiting() { } @Test - public void clusterWith3Nodes_someSuspended_someRunning() { + void clusterWith3Nodes_someSuspended_someRunning() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -178,7 +178,7 @@ public void clusterWith3Nodes_someSuspended_someRunning() { } @Test - public void clusterWith3Nodes_someWaiting_someRunning() { + void clusterWith3Nodes_someWaiting_someRunning() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.WAITING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -191,7 +191,7 @@ public void clusterWith3Nodes_someWaiting_someRunning() { } @Test - public void clusterWith3Nodes_someSuspended_someWaiting_someRunning() { + void clusterWith3Nodes_someSuspended_someWaiting_someRunning() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.SUSPENDED, isOtherStatic() ? otherShardAssignmentIn4NodeCluster( 1 ) : null ) @@ -204,7 +204,7 @@ public void clusterWith3Nodes_someSuspended_someWaiting_someRunning() { } @Test - public void clusterWith3Nodes_allSuspended() { + void clusterWith3Nodes_allSuspended() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.SUSPENDED, isOtherStatic() ? otherShardAssignmentIn4NodeCluster( 1 ) : null ) @@ -217,7 +217,7 @@ public void clusterWith3Nodes_allSuspended() { } @Test - public void clusterWith3Nodes_allWaiting() { + void clusterWith3Nodes_allWaiting() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.WAITING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -230,7 +230,7 @@ public void clusterWith3Nodes_allWaiting() { } @Test - public void clusterWith3Nodes_allRunning() { + void clusterWith3Nodes_allRunning() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -243,7 +243,7 @@ public void clusterWith3Nodes_allRunning() { } @Test - public void clusterWith3Nodes_someExpired_massIndexingAgent_running() { + void clusterWith3Nodes_someExpired_massIndexingAgent_running() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -263,7 +263,7 @@ public void clusterWith3Nodes_someExpired_massIndexingAgent_running() { } @Test - public void clusterWith3Nodes_someSuspended_someRunning_massIndexingAgent_running() { + void clusterWith3Nodes_someSuspended_someRunning_massIndexingAgent_running() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -279,7 +279,7 @@ public void clusterWith3Nodes_someSuspended_someRunning_massIndexingAgent_runnin } @Test - public void clusterWith3Nodes_allSuspended_massIndexingAgent_running() { + void clusterWith3Nodes_allSuspended_massIndexingAgent_running() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.SUSPENDED, isOtherStatic() ? otherShardAssignmentIn4NodeCluster( 1 ) : null ) @@ -295,7 +295,7 @@ public void clusterWith3Nodes_allSuspended_massIndexingAgent_running() { } @Test - public void clusterWith3Nodes_allSuspended_massIndexingAgent_suspended() { + void clusterWith3Nodes_allSuspended_massIndexingAgent_suspended() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.SUSPENDED, isOtherStatic() ? otherShardAssignmentIn4NodeCluster( 1 ) : null ) @@ -312,7 +312,7 @@ public void clusterWith3Nodes_allSuspended_massIndexingAgent_suspended() { } @Test - public void clusterWith3Nodes_allSuspended_massIndexingAgent_waiting() { + void clusterWith3Nodes_allSuspended_massIndexingAgent_waiting() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.SUSPENDED, isOtherStatic() ? otherShardAssignmentIn4NodeCluster( 1 ) : null ) @@ -329,7 +329,7 @@ public void clusterWith3Nodes_allSuspended_massIndexingAgent_waiting() { } @Test - public void clusterWith3Nodes_allSuspended_massIndexingAgent_expired() { + void clusterWith3Nodes_allSuspended_massIndexingAgent_expired() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.SUSPENDED, isOtherStatic() ? otherShardAssignmentIn4NodeCluster( 1 ) : null ) @@ -348,7 +348,7 @@ public void clusterWith3Nodes_allSuspended_massIndexingAgent_expired() { } @Test - public void clusterWith3Nodes_allRunning_massIndexingAgent_running() { + void clusterWith3Nodes_allRunning_massIndexingAgent_running() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -362,7 +362,7 @@ public void clusterWith3Nodes_allRunning_massIndexingAgent_running() { } @Test - public void clusterWith3Nodes_allRunning_massIndexingAgent_suspended() { + void clusterWith3Nodes_allRunning_massIndexingAgent_suspended() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -379,7 +379,7 @@ public void clusterWith3Nodes_allRunning_massIndexingAgent_suspended() { } @Test - public void clusterWith3Nodes_allRunning_massIndexingAgent_waiting() { + void clusterWith3Nodes_allRunning_massIndexingAgent_waiting() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) @@ -396,7 +396,7 @@ public void clusterWith3Nodes_allRunning_massIndexingAgent_waiting() { } @Test - public void clusterWith3Nodes_allRunning_massIndexingAgent_expired() { + void clusterWith3Nodes_allRunning_massIndexingAgent_expired() { repositoryMockHelper.defineOtherAgents() .other( other1Id(), otherType(), LATER, AgentState.RUNNING, otherShardAssignmentIn4NodeCluster( 1 ) ) diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractMassIndexerAgentClusterLinkTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractMassIndexerAgentClusterLinkTest.java index 6c06c98357c..1914757a549 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractMassIndexerAgentClusterLinkTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/AbstractMassIndexerAgentClusterLinkTest.java @@ -28,15 +28,17 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentState; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentType; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) abstract class AbstractMassIndexerAgentClusterLinkTest { static final Instant NOW = Instant.parse( "2021-11-21T14:30:00.000Z" ); @@ -54,9 +56,6 @@ abstract class AbstractMassIndexerAgentClusterLinkTest { static final UUID SELF_ID = toUUID( SELF_ID_ORDINAL ); static final AgentReference SELF_REF = AgentReference.of( SELF_ID, "Self Agent Name" ); - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); - @Mock public FailureHandler failureHandlerMock; @@ -73,8 +72,8 @@ abstract class AbstractMassIndexerAgentClusterLinkTest { protected AgentRepositoryMockingHelper repositoryMockHelper; - @Before - public final void initMocks() { + @BeforeEach + final void initMocks() { repositoryMockHelper = new AgentRepositoryMockingHelper( repositoryMock ); Collections.addAll( allMocks, failureHandlerMock, clockMock, repositoryMock ); @@ -83,8 +82,8 @@ public final void initMocks() { doNothing().when( contextMock ).commitAndBeginNewTransaction(); } - @After - public void verifyNoMoreInvocationsOnAllMocks() { + @AfterEach + void verifyNoMoreInvocationsOnAllMocks() { verifyNoMoreInteractions( allMocks.toArray() ); } diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkDynamicShardingBaseTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkDynamicShardingBaseTest.java index df8dcc09b6c..aba9395454f 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkDynamicShardingBaseTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkDynamicShardingBaseTest.java @@ -11,18 +11,15 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentState; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentType; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.ShardAssignmentDescriptor; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; /** * Base tests of {@link OutboxPollingEventProcessorClusterLink} * with dynamic sharding. */ -@RunWith(NestedRunner.class) -public class EventProcessorClusterLinkDynamicShardingBaseTest { +class EventProcessorClusterLinkDynamicShardingBaseTest { abstract static class AbstractBaseTest extends AbstractEventProcessorClusterLinkBaseTest { // Define IDs in ascending order, because IDs matter when using dynamic sharding. @@ -94,7 +91,7 @@ public void clusterWith4Nodes_allRunning_clusterExcludingSelf() { // but should go through the waiting state first. // See comments in OutboxPollingEventProcessorClusterLink. @Nested - public static class NotRegisteredTest extends AbstractBaseTest { + public class NotRegisteredTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfNotCreatedYet(); @@ -112,7 +109,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class SuspendedTest extends AbstractBaseTest { + public class SuspendedTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.SUSPENDED, null ); @@ -130,7 +127,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class WaitingIn1NodeClusterTest extends AbstractBaseTest { + public class WaitingIn1NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.WAITING, selfShardAssignmentIn1NodeCluster() ); @@ -149,7 +146,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class RunningIn1NodeClusterTest extends AbstractBaseTest { + public class RunningIn1NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.RUNNING, selfShardAssignmentIn1NodeCluster() ); @@ -167,7 +164,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class WaitingIn3NodeClusterTest extends AbstractBaseTest { + public class WaitingIn3NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.WAITING, selfShardAssignmentIn3NodeCluster() ); @@ -185,7 +182,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class RunningIn3NodeClusterTest extends AbstractBaseTest { + public class RunningIn3NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.RUNNING, selfShardAssignmentIn3NodeCluster() ); @@ -203,7 +200,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class WaitingIn4NodeClusterTest extends AbstractBaseTest { + public class WaitingIn4NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.WAITING, selfShardAssignmentIn4NodeCluster() ); @@ -222,7 +219,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class RunningIn4NodeClusterTest extends AbstractBaseTest { + public class RunningIn4NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.RUNNING, selfShardAssignmentIn4NodeCluster() ); @@ -241,7 +238,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class WaitingIn5NodeClusterTest extends AbstractBaseTest { + public class WaitingIn5NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.WAITING, shardAssignmentIn5NodeCluster() ); @@ -259,7 +256,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class RunningIn5NodeClusterTest extends AbstractBaseTest { + public class RunningIn5NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.RUNNING, shardAssignmentIn5NodeCluster() ); diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkLeaveClusterTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkLeaveClusterTest.java index 2f2acbc5258..52d05df6233 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkLeaveClusterTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkLeaveClusterTest.java @@ -11,12 +11,12 @@ import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for {@link OutboxPollingEventProcessorClusterLink#leaveCluster(AgentClusterLinkContextProvider)}. */ -public class EventProcessorClusterLinkLeaveClusterTest extends AbstractEventProcessorClusterLinkTest { +class EventProcessorClusterLinkLeaveClusterTest extends AbstractEventProcessorClusterLinkTest { final OutboxPollingEventProcessorClusterLink setupLink() { return new OutboxPollingEventProcessorClusterLink( SELF_REF.name, failureHandlerMock, clockMock, shardAssignmentProviderStub, @@ -26,13 +26,13 @@ final OutboxPollingEventProcessorClusterLink setupLink() { } @Test - public void didNotJoin() { + void didNotJoin() { OutboxPollingEventProcessorClusterLink link = setupLink(); link.leaveCluster( contextMock ); } @Test - public void joined_found() { + void joined_found() { OutboxPollingEventProcessorClusterLink link = setupLink(); defineSelfNotCreatedYet( link ); repositoryMockHelper.defineOtherAgents(); @@ -46,7 +46,7 @@ public void joined_found() { } @Test - public void joined_notFound() { + void joined_notFound() { OutboxPollingEventProcessorClusterLink link = setupLink(); defineSelfNotCreatedYet( link ); repositoryMockHelper.defineOtherAgents(); diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkMixedSharding4ShardSelfDynamicBaseTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkMixedSharding4ShardSelfDynamicBaseTest.java index c3fccabee73..f3a29f86564 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkMixedSharding4ShardSelfDynamicBaseTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkMixedSharding4ShardSelfDynamicBaseTest.java @@ -10,10 +10,8 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentState; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentType; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; /** * Base tests of {@link OutboxPollingEventProcessorClusterLink} @@ -21,8 +19,7 @@ * with a total shard count of 4, * self being static. */ -@RunWith(NestedRunner.class) -public class EventProcessorClusterLinkMixedSharding4ShardSelfDynamicBaseTest { +class EventProcessorClusterLinkMixedSharding4ShardSelfDynamicBaseTest { abstract static class AbstractBaseTest extends AbstractEventProcessorClusterLinkBaseTest { @@ -89,7 +86,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class SuspendedTest extends AbstractBaseTest { + public class SuspendedTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.SUSPENDED, null ); @@ -107,7 +104,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class WaitingIn4NodeClusterTest extends AbstractBaseTest { + public class WaitingIn4NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { @@ -127,7 +124,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class RunningIn4NodeClusterTest extends AbstractBaseTest { + public class RunningIn4NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.RUNNING, selfShardAssignmentIn4NodeCluster() ); diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkMixedSharding4ShardSelfStaticBaseTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkMixedSharding4ShardSelfStaticBaseTest.java index 35da2fd2595..fc3d9205743 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkMixedSharding4ShardSelfStaticBaseTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkMixedSharding4ShardSelfStaticBaseTest.java @@ -10,10 +10,8 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentState; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentType; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; /** * Base tests of {@link OutboxPollingEventProcessorClusterLink} @@ -21,8 +19,7 @@ * with a total shard count of 4, * self being static. */ -@RunWith(NestedRunner.class) -public class EventProcessorClusterLinkMixedSharding4ShardSelfStaticBaseTest { +class EventProcessorClusterLinkMixedSharding4ShardSelfStaticBaseTest { abstract static class AbstractBaseTest extends AbstractEventProcessorClusterLinkBaseTest { @@ -75,7 +72,7 @@ protected AgentType other3Type() { // but should go through the waiting state first. // See comments in OutboxPollingEventProcessorClusterLink. @Nested - public static class NotRegisteredTest extends AbstractBaseTest { + public class NotRegisteredTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfNotCreatedYet(); @@ -93,7 +90,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class SuspendedTest extends AbstractBaseTest { + public class SuspendedTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.SUSPENDED, selfStaticShardAssignment() ); @@ -111,7 +108,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class WaitingIn4NodeClusterTest extends AbstractBaseTest { + public class WaitingIn4NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { @@ -131,7 +128,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class RunningIn4NodeClusterTest extends AbstractBaseTest { + public class RunningIn4NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.RUNNING, selfShardAssignmentIn4NodeCluster() ); diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkStaticSharding4ShardBaseTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkStaticSharding4ShardBaseTest.java index c18c64931cc..4e6ae356bf0 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkStaticSharding4ShardBaseTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkStaticSharding4ShardBaseTest.java @@ -10,17 +10,14 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentState; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentType; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; /** * Base tests of {@link OutboxPollingEventProcessorClusterLink} * with static sharding with a total shard count of 4. */ -@RunWith(NestedRunner.class) -public class EventProcessorClusterLinkStaticSharding4ShardBaseTest { +class EventProcessorClusterLinkStaticSharding4ShardBaseTest { abstract static class AbstractBaseTest extends AbstractEventProcessorClusterLinkBaseTest { @@ -69,7 +66,7 @@ protected AgentType other3Type() { // but should go through the waiting state first. // See comments in OutboxPollingEventProcessorClusterLink. @Nested - public static class NotRegisteredTest extends AbstractBaseTest { + public class NotRegisteredTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfNotCreatedYet(); @@ -87,7 +84,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class SuspendedTest extends AbstractBaseTest { + public class SuspendedTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.SUSPENDED, selfStaticShardAssignment() ); @@ -105,7 +102,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class WaitingIn4NodeClusterTest extends AbstractBaseTest { + public class WaitingIn4NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { @@ -125,7 +122,7 @@ protected EventProcessorClusterLinkPulseExpectations onClusterWith4NodesAllOther } @Nested - public static class RunningIn4NodeClusterTest extends AbstractBaseTest { + public class RunningIn4NodeClusterTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.RUNNING, selfShardAssignmentIn4NodeCluster() ); diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkStaticShardingEdgeCasesTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkStaticShardingEdgeCasesTest.java index f703ccd34de..aacc2128b3c 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkStaticShardingEdgeCasesTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/EventProcessorClusterLinkStaticShardingEdgeCasesTest.java @@ -18,15 +18,15 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.ShardAssignmentDescriptor; import org.hibernate.search.util.common.SearchException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; /** * Tests edge cases of static sharding. */ -public class EventProcessorClusterLinkStaticShardingEdgeCasesTest +class EventProcessorClusterLinkStaticShardingEdgeCasesTest extends AbstractEventProcessorClusterLinkTest { private static final UUID OTHER_0_ID = toUUID( SELF_ID_ORDINAL - 1 ); private static final UUID OTHER_1_ID = toUUID( SELF_ID_ORDINAL + 1 ); @@ -42,14 +42,14 @@ final OutboxPollingEventProcessorClusterLink setupLink(ShardAssignmentDescriptor ); } - @Before - public void initPulseMocks() { + @BeforeEach + void initPulseMocks() { when( repositoryMock.findAllOrderById() ).thenAnswer( ignored -> repositoryMockHelper.allAgentsInIdOrder() ); when( clockMock.instant() ).thenReturn( NOW ); } @Test - public void selfExpires_rejoin() { + void selfExpires_rejoin() { OutboxPollingEventProcessorClusterLink link = setupLink( null ); defineSelfNotCreatedYet( link ); @@ -85,7 +85,7 @@ public void selfExpires_rejoin() { } @Test - public void staticSharding_conflictingAssignedShardIds() { + void staticSharding_conflictingAssignedShardIds() { int totalShardCount = 3; ShardAssignmentDescriptor selfStaticShardAssignment = new ShardAssignmentDescriptor( totalShardCount, 1 ); @@ -126,7 +126,7 @@ public void staticSharding_conflictingAssignedShardIds() { } @Test - public void staticSharding_conflictingTotalShardCount() { + void staticSharding_conflictingTotalShardCount() { ShardAssignmentDescriptor selfStaticShardAssignment = new ShardAssignmentDescriptor( 3, 1 ); @@ -166,7 +166,7 @@ public void staticSharding_conflictingTotalShardCount() { } @Test - public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentsReady_extraAgentsSuspended() { + void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentsReady_extraAgentsSuspended() { int totalShardCount = 4; ShardAssignmentDescriptor selfStaticShardAssignment = new ShardAssignmentDescriptor( totalShardCount, 1 ); @@ -192,7 +192,7 @@ public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentsRead } @Test - public void mixedSharding_otherDynamicSuperfluous_selfSuspended_includedAgentsReady_extraAgentsSuspended() { + void mixedSharding_otherDynamicSuperfluous_selfSuspended_includedAgentsReady_extraAgentsSuspended() { int totalShardCount = 4; ShardAssignmentDescriptor selfStaticShardAssignment = new ShardAssignmentDescriptor( totalShardCount, 1 ); @@ -218,7 +218,7 @@ public void mixedSharding_otherDynamicSuperfluous_selfSuspended_includedAgentsRe } @Test - public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentSuspended_extraAgentsSuspended() { + void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentSuspended_extraAgentsSuspended() { int totalShardCount = 4; ShardAssignmentDescriptor selfStaticShardAssignment = new ShardAssignmentDescriptor( totalShardCount, 1 ); @@ -244,7 +244,7 @@ public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentSuspe } @Test - public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentInWrongCluster_extraAgentsSuspended() { + void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentInWrongCluster_extraAgentsSuspended() { int totalShardCount = 4; ShardAssignmentDescriptor selfStaticShardAssignment = new ShardAssignmentDescriptor( totalShardCount, 1 ); @@ -270,7 +270,7 @@ public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentInWro } @Test - public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentsReady_extraAgentsRunning() { + void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentsReady_extraAgentsRunning() { int totalShardCount = 4; ShardAssignmentDescriptor selfStaticShardAssignment = new ShardAssignmentDescriptor( totalShardCount, 1 ); @@ -297,7 +297,7 @@ public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentsRead } @Test - public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentsReady_extraAgentsWaiting() { + void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentsReady_extraAgentsWaiting() { int totalShardCount = 4; ShardAssignmentDescriptor selfStaticShardAssignment = new ShardAssignmentDescriptor( totalShardCount, 1 ); @@ -324,7 +324,7 @@ public void mixedSharding_otherDynamicSuperfluous_selfWaiting_includedAgentsRead } @Test - public void mixedSharding_selfDynamicSuperfluous_selfWaiting_includedAgentsReady_extraAgentsSuspended() { + void mixedSharding_selfDynamicSuperfluous_selfWaiting_includedAgentsReady_extraAgentsSuspended() { int totalShardCount = 4; OutboxPollingEventProcessorClusterLink link = setupLink( null ); diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkDynamicShardingBaseTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkDynamicShardingBaseTest.java index 62e1c965c6e..b44ef8fefc6 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkDynamicShardingBaseTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkDynamicShardingBaseTest.java @@ -12,17 +12,14 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentState; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentType; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; /** * Base tests of {@link OutboxPollingMassIndexerAgentClusterLink} * with event processors using dynamic sharding. */ -@RunWith(NestedRunner.class) -public class MassIndexerAgentClusterLinkDynamicShardingBaseTest { +class MassIndexerAgentClusterLinkDynamicShardingBaseTest { abstract static class AbstractBaseTest extends AbstractMassIndexerAgentClusterLinkBaseTest { @@ -56,7 +53,7 @@ protected AgentType otherType() { // but should go through the waiting state first. // See comments in OutboxPollingMassIndexerAgentClusterLink. @Nested - public static class NotRegisteredTest extends AbstractBaseTest { + public class NotRegisteredTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfNotCreatedYet(); @@ -74,7 +71,7 @@ protected MassIndexerAgentClusterLinkPulseExpectations onClusterWith3NodesAll3No } @Nested - public static class SuspendedTest extends AbstractBaseTest { + public class SuspendedTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.SUSPENDED ); @@ -92,7 +89,7 @@ protected MassIndexerAgentClusterLinkPulseExpectations onClusterWith3NodesAll3No } @Nested - public static class WaitingTest extends AbstractBaseTest { + public class WaitingTest extends AbstractBaseTest { @Override protected void defineSelf() { @@ -113,7 +110,7 @@ protected MassIndexerAgentClusterLinkPulseExpectations onClusterWith3NodesAll3No } @Nested - public static class RunningTest extends AbstractBaseTest { + public class RunningTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.RUNNING ); diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkLeaveClusterTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkLeaveClusterTest.java index d507a648c85..8dcb7c6b350 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkLeaveClusterTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkLeaveClusterTest.java @@ -11,12 +11,12 @@ import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for {@link OutboxPollingMassIndexerAgentClusterLink#leaveCluster(AgentClusterLinkContextProvider)}. */ -public class MassIndexerAgentClusterLinkLeaveClusterTest extends AbstractMassIndexerAgentClusterLinkTest { +class MassIndexerAgentClusterLinkLeaveClusterTest extends AbstractMassIndexerAgentClusterLinkTest { final OutboxPollingMassIndexerAgentClusterLink setupLink() { return new OutboxPollingMassIndexerAgentClusterLink( SELF_REF.name, failureHandlerMock, clockMock, @@ -25,13 +25,13 @@ final OutboxPollingMassIndexerAgentClusterLink setupLink() { } @Test - public void didNotJoin() { + void didNotJoin() { OutboxPollingMassIndexerAgentClusterLink link = setupLink(); link.leaveCluster( contextMock ); } @Test - public void joined_found() { + void joined_found() { OutboxPollingMassIndexerAgentClusterLink link = setupLink(); defineSelfNotCreatedYet( link ); repositoryMockHelper.defineOtherAgents(); @@ -45,7 +45,7 @@ public void joined_found() { } @Test - public void joined_notFound() { + void joined_notFound() { OutboxPollingMassIndexerAgentClusterLink link = setupLink(); defineSelfNotCreatedYet( link ); repositoryMockHelper.defineOtherAgents(); diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkStaticSharding3ShardBaseTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkStaticSharding3ShardBaseTest.java index f6496fe5fea..3933489dd8e 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkStaticSharding3ShardBaseTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/event/impl/MassIndexerAgentClusterLinkStaticSharding3ShardBaseTest.java @@ -12,17 +12,14 @@ import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentState; import org.hibernate.search.mapper.orm.coordination.outboxpolling.cluster.impl.AgentType; -import org.hibernate.search.util.impl.test.runner.nested.Nested; -import org.hibernate.search.util.impl.test.runner.nested.NestedRunner; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; /** * Base tests of {@link OutboxPollingMassIndexerAgentClusterLink} * with event processors using static sharding with a total shard count of 3. */ -@RunWith(NestedRunner.class) -public class MassIndexerAgentClusterLinkStaticSharding3ShardBaseTest { +class MassIndexerAgentClusterLinkStaticSharding3ShardBaseTest { abstract static class AbstractBaseTest extends AbstractMassIndexerAgentClusterLinkBaseTest { @@ -56,7 +53,7 @@ protected AgentType otherType() { // but should go through the waiting state first. // See comments in OutboxPollingMassIndexerAgentClusterLink. @Nested - public static class NotRegisteredTest extends AbstractBaseTest { + public class NotRegisteredTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfNotCreatedYet(); @@ -74,7 +71,7 @@ protected MassIndexerAgentClusterLinkPulseExpectations onClusterWith3NodesAll3No } @Nested - public static class SuspendedTest extends AbstractBaseTest { + public class SuspendedTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.SUSPENDED ); @@ -92,7 +89,7 @@ protected MassIndexerAgentClusterLinkPulseExpectations onClusterWith3NodesAll3No } @Nested - public static class WaitingTest extends AbstractBaseTest { + public class WaitingTest extends AbstractBaseTest { @Override protected void defineSelf() { @@ -113,7 +110,7 @@ protected MassIndexerAgentClusterLinkPulseExpectations onClusterWith3NodesAll3No } @Nested - public static class RunningTest extends AbstractBaseTest { + public class RunningTest extends AbstractBaseTest { @Override protected void defineSelf() { defineSelfCreatedAndStillPresent( AgentState.RUNNING ); diff --git a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/mapping/spi/HibernateOrmMapperOutboxPollingClassesTest.java b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/mapping/spi/HibernateOrmMapperOutboxPollingClassesTest.java index 852bafc6a80..7722785f4ea 100644 --- a/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/mapping/spi/HibernateOrmMapperOutboxPollingClassesTest.java +++ b/mapper/orm-coordination-outbox-polling/src/test/java/org/hibernate/search/mapper/orm/coordination/outboxpolling/mapping/spi/HibernateOrmMapperOutboxPollingClassesTest.java @@ -21,8 +21,8 @@ import org.hibernate.search.util.common.AssertionFailure; import org.hibernate.search.util.common.jar.impl.JandexUtils; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.ClassInfo; @@ -37,12 +37,12 @@ /** * Tests that hardcoded lists of classes stay up-to-date. */ -public class HibernateOrmMapperOutboxPollingClassesTest { +class HibernateOrmMapperOutboxPollingClassesTest { private static Index outboxPollingIndex; - @BeforeClass - public static void index() { + @BeforeAll + static void index() { outboxPollingIndex = readOrBuildIndex( codeSourceLocation( HibernateOrmMapperOutboxPollingSettings.class ) .orElseThrow( () -> new AssertionFailure( @@ -51,7 +51,7 @@ public static void index() { } @Test - public void testNoMissingAvroGeneratedClass() { + void testNoMissingAvroGeneratedClass() { Set annotatedClasses = new HashSet<>(); for ( AnnotationInstance annotationInstance : outboxPollingIndex .getAnnotations( DotName.createSimple( AvroGenerated.class.getName() ) ) ) { @@ -65,7 +65,7 @@ public void testNoMissingAvroGeneratedClass() { } @Test - public void testNoMissingJpaModelClass() { + void testNoMissingJpaModelClass() { Set modelClasses = collectModelClassesRecursively( outboxPollingIndex, new HashSet<>( Arrays.asList( DotName.createSimple( OutboxEvent.class.getName() ), DotName.createSimple( Agent.class.getName() ) diff --git a/mapper/orm-jakarta-batch/core/src/test/java/org/hibernate/search/jakarta/batch/core/massindexing/MassIndexingJobParametersBuilderTest.java b/mapper/orm-jakarta-batch/core/src/test/java/org/hibernate/search/jakarta/batch/core/massindexing/MassIndexingJobParametersBuilderTest.java index cb0c2890a0d..00ca862e2c7 100644 --- a/mapper/orm-jakarta-batch/core/src/test/java/org/hibernate/search/jakarta/batch/core/massindexing/MassIndexingJobParametersBuilderTest.java +++ b/mapper/orm-jakarta-batch/core/src/test/java/org/hibernate/search/jakarta/batch/core/massindexing/MassIndexingJobParametersBuilderTest.java @@ -6,24 +6,24 @@ */ package org.hibernate.search.jakarta.batch.core.massindexing; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Properties; +import java.util.stream.Collectors; import org.hibernate.CacheMode; import org.hibernate.search.util.common.SearchException; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Mincong Huang */ -public class MassIndexingJobParametersBuilderTest { +class MassIndexingJobParametersBuilderTest { private static final String SESSION_FACTORY_NAME = "someUniqueString"; @@ -41,7 +41,7 @@ public class MassIndexingJobParametersBuilderTest { private static final CacheMode CACHE_MODE = CacheMode.GET; @Test - public void testJobParamsAll() throws IOException { + void testJobParamsAll() throws IOException { Properties props = MassIndexingJob.parameters() .forEntities( String.class, Integer.class ) .entityManagerFactoryReference( SESSION_FACTORY_NAME ) @@ -58,50 +58,39 @@ public void testJobParamsAll() throws IOException { .tenantId( TENANT_ID ) .build(); - assertEquals( - SESSION_FACTORY_NAME, props.getProperty( MassIndexingJobParameters.ENTITY_MANAGER_FACTORY_REFERENCE ) ); - assertEquals( ID_FETCH_SIZE, Integer.parseInt( props.getProperty( MassIndexingJobParameters.ID_FETCH_SIZE ) ) ); - assertEquals( - ENTITY_FETCH_SIZE, - Integer.parseInt( props.getProperty( MassIndexingJobParameters.ENTITY_FETCH_SIZE ) ) - ); - assertEquals( - MAX_RESULTS_PER_ENTITY, - Integer.parseInt( props.getProperty( MassIndexingJobParameters.MAX_RESULTS_PER_ENTITY ) ) - ); - assertEquals( - MERGE_SEGMENTS_AFTER_PURGE, - Boolean.parseBoolean( props.getProperty( MassIndexingJobParameters.MERGE_SEGMENTS_AFTER_PURGE ) ) - ); - assertEquals( - MERGE_SEGMENTS_ON_FINISH, - Boolean.parseBoolean( props.getProperty( MassIndexingJobParameters.MERGE_SEGMENTS_ON_FINISH ) ) - ); - assertEquals( - ROWS_PER_PARTITION, - Integer.parseInt( props.getProperty( MassIndexingJobParameters.ROWS_PER_PARTITION ) ) - ); - assertEquals( - CHECKPOINT_INTERVAL, - Integer.parseInt( props.getProperty( MassIndexingJobParameters.CHECKPOINT_INTERVAL ) ) - ); - assertEquals( - PURGE_ALL_ON_START, - Boolean.parseBoolean( props.getProperty( MassIndexingJobParameters.PURGE_ALL_ON_START ) ) - ); - assertEquals( MAX_THREADS, Integer.parseInt( props.getProperty( MassIndexingJobParameters.MAX_THREADS ) ) ); - assertEquals( CACHE_MODE, CacheMode.valueOf( props.getProperty( MassIndexingJobParameters.CACHE_MODE ) ) ); - assertEquals( TENANT_ID, props.getProperty( MassIndexingJobParameters.TENANT_ID ) ); + assertThat( props.getProperty( MassIndexingJobParameters.ENTITY_MANAGER_FACTORY_REFERENCE ) ) + .isEqualTo( SESSION_FACTORY_NAME ); + assertThat( Integer.parseInt( props.getProperty( MassIndexingJobParameters.ID_FETCH_SIZE ) ) ) + .isEqualTo( ID_FETCH_SIZE ); + assertThat( Integer.parseInt( props.getProperty( MassIndexingJobParameters.ENTITY_FETCH_SIZE ) ) ) + .isEqualTo( ENTITY_FETCH_SIZE ); + assertThat( Integer.parseInt( props.getProperty( MassIndexingJobParameters.MAX_RESULTS_PER_ENTITY ) ) ) + .isEqualTo( MAX_RESULTS_PER_ENTITY ); + assertThat( Boolean.parseBoolean( props.getProperty( MassIndexingJobParameters.MERGE_SEGMENTS_AFTER_PURGE ) ) ) + .isEqualTo( MERGE_SEGMENTS_AFTER_PURGE ); + assertThat( Boolean.parseBoolean( props.getProperty( MassIndexingJobParameters.MERGE_SEGMENTS_ON_FINISH ) ) ) + .isEqualTo( MERGE_SEGMENTS_ON_FINISH ); + assertThat( Integer.parseInt( props.getProperty( MassIndexingJobParameters.ROWS_PER_PARTITION ) ) ) + .isEqualTo( ROWS_PER_PARTITION ); + assertThat( Integer.parseInt( props.getProperty( MassIndexingJobParameters.CHECKPOINT_INTERVAL ) ) ) + .isEqualTo( CHECKPOINT_INTERVAL ); + assertThat( Boolean.parseBoolean( props.getProperty( MassIndexingJobParameters.PURGE_ALL_ON_START ) ) ) + .isEqualTo( PURGE_ALL_ON_START ); + assertThat( Integer.parseInt( props.getProperty( MassIndexingJobParameters.MAX_THREADS ) ) ).isEqualTo( MAX_THREADS ); + assertThat( CacheMode.valueOf( props.getProperty( MassIndexingJobParameters.CACHE_MODE ) ) ).isEqualTo( CACHE_MODE ); + assertThat( props.getProperty( MassIndexingJobParameters.TENANT_ID ) ).isEqualTo( TENANT_ID ); String entityTypes = props.getProperty( MassIndexingJobParameters.ENTITY_TYPES ); - List entityNames = Arrays.asList( entityTypes.split( "," ) ); - entityNames.forEach( entityName -> entityName = entityName.trim() ); - assertTrue( entityNames.contains( Integer.class.getName() ) ); - assertTrue( entityNames.contains( String.class.getName() ) ); + List entityNames = Arrays.stream( entityTypes.split( "," ) ) + .map( String::trim ) + .collect( Collectors.toList() ); + assertThat( entityNames ) + .contains( Integer.class.getName() ) + .contains( String.class.getName() ); } @Test - public void testForEntities_notNull() throws IOException { + void testForEntities_notNull() throws IOException { Properties props = MassIndexingJob.parameters() .forEntities( Integer.class, String.class ) .entityManagerFactoryReference( SESSION_FACTORY_NAME ) @@ -109,13 +98,11 @@ public void testForEntities_notNull() throws IOException { String entityTypes = props.getProperty( MassIndexingJobParameters.ENTITY_TYPES ); List entityNames = Arrays.asList( entityTypes.split( "," ) ); - entityNames.forEach( entityName -> entityName = entityName.trim() ); - assertTrue( entityNames.contains( Integer.class.getName() ) ); - assertTrue( entityNames.contains( String.class.getName() ) ); + assertThat( entityNames ).contains( Integer.class.getName(), String.class.getName() ); } @Test - public void testForEntity_notNull() throws IOException { + void testForEntity_notNull() throws IOException { Properties props = MassIndexingJob.parameters() .forEntity( Integer.class ) .build(); @@ -123,30 +110,34 @@ public void testForEntity_notNull() throws IOException { String entityTypes = props.getProperty( MassIndexingJobParameters.ENTITY_TYPES ); List entityNames = Arrays.asList( entityTypes.split( "," ) ); entityNames.forEach( entityName -> entityName = entityName.trim() ); - assertTrue( entityNames.contains( Integer.class.getName() ) ); + assertThat( entityNames ).contains( Integer.class.getName() ); } - @Test(expected = IllegalArgumentException.class) - public void testForEntity_null() { - MassIndexingJob.parameters().forEntity( null ); + @Test + void testForEntity_null() { + assertThatThrownBy( () -> MassIndexingJob.parameters().forEntity( null ) ) + .isInstanceOf( IllegalArgumentException.class ); } - @Test(expected = NullPointerException.class) - public void testRestrictedBy_stringNull() { - MassIndexingJob.parameters().forEntity( String.class ).restrictedBy( (String) null ); + @Test + void testRestrictedBy_stringNull() { + assertThatThrownBy( + () -> MassIndexingJob.parameters().forEntity( String.class ).restrictedBy( (String) null ) ) + .isInstanceOf( NullPointerException.class ); } - @Test(expected = SearchException.class) - public void testSessionClearInterval_greaterThanCheckpointInterval() { - MassIndexingJob.parameters() + @Test + void testSessionClearInterval_greaterThanCheckpointInterval() { + assertThatThrownBy( () -> MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) .sessionClearInterval( 5 ) .checkpointInterval( 4 ) - .build(); + .build() ) + .isInstanceOf( SearchException.class ); } @Test - public void testSessionClearInterval_defaultGreaterThanCheckpointInterval() { + void testSessionClearInterval_defaultGreaterThanCheckpointInterval() { MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) .checkpointInterval( MassIndexingJobParameters.Defaults.SESSION_CLEAR_INTERVAL_DEFAULT_RAW - 1 ) @@ -154,25 +145,27 @@ public void testSessionClearInterval_defaultGreaterThanCheckpointInterval() { // ok, session clear interval will default to the value of checkpointInterval } - @Test(expected = SearchException.class) - public void testSessionClearInterval_greaterThanDefaultCheckpointInterval() { - MassIndexingJob.parameters() + @Test + void testSessionClearInterval_greaterThanDefaultCheckpointInterval() { + assertThatThrownBy( () -> MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) .sessionClearInterval( MassIndexingJobParameters.Defaults.CHECKPOINT_INTERVAL_DEFAULT_RAW + 1 ) - .build(); + .build() ) + .isInstanceOf( SearchException.class ); } - @Test(expected = SearchException.class) - public void testCheckpointInterval_greaterThanRowsPerPartitions() { - MassIndexingJob.parameters() + @Test + void testCheckpointInterval_greaterThanRowsPerPartitions() { + assertThatThrownBy( () -> MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) .checkpointInterval( 5 ) .rowsPerPartition( 4 ) - .build(); + .build() ) + .isInstanceOf( SearchException.class ); } @Test - public void testCheckpointInterval_defaultGreaterThanRowsPerPartitions() { + void testCheckpointInterval_defaultGreaterThanRowsPerPartitions() { MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) .rowsPerPartition( MassIndexingJobParameters.Defaults.CHECKPOINT_INTERVAL_DEFAULT_RAW - 1 ) @@ -180,16 +173,17 @@ public void testCheckpointInterval_defaultGreaterThanRowsPerPartitions() { // ok, checkpoint interval will default to the value of rowsPerPartition } - @Test(expected = SearchException.class) - public void testCheckpointInterval_greaterThanDefaultRowsPerPartitions() { - MassIndexingJob.parameters() + @Test + void testCheckpointInterval_greaterThanDefaultRowsPerPartitions() { + assertThatThrownBy( () -> MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) .checkpointInterval( MassIndexingJobParameters.Defaults.ROWS_PER_PARTITION + 1 ) - .build(); + .build() ) + .isInstanceOf( SearchException.class ); } @Test - public void testTenantId_null() throws Exception { + void testTenantId_null() throws Exception { assertThatThrownBy( () -> MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) .tenantId( null ) ) @@ -198,7 +192,7 @@ public void testTenantId_null() throws Exception { } @Test - public void testTenantId_empty() throws Exception { + void testTenantId_empty() throws Exception { assertThatThrownBy( () -> MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) .tenantId( "" ) ) @@ -207,7 +201,7 @@ public void testTenantId_empty() throws Exception { } @Test - public void testIdFetchSize() throws Exception { + void testIdFetchSize() throws Exception { for ( int allowedValue : Arrays.asList( Integer.MAX_VALUE, 0, Integer.MIN_VALUE ) ) { MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) @@ -216,7 +210,7 @@ public void testIdFetchSize() throws Exception { } @Test - public void testEntityFetchSize() throws Exception { + void testEntityFetchSize() throws Exception { for ( int allowedValue : Arrays.asList( Integer.MAX_VALUE, 0, Integer.MIN_VALUE ) ) { MassIndexingJob.parameters() .forEntity( UnusedEntity.class ) diff --git a/mapper/orm-jakarta-batch/core/src/test/java/org/hibernate/search/jakarta/batch/core/massindexing/util/impl/SerializationUtilTest.java b/mapper/orm-jakarta-batch/core/src/test/java/org/hibernate/search/jakarta/batch/core/massindexing/util/impl/SerializationUtilTest.java index d653d05fa8d..06ee3a60a2c 100644 --- a/mapper/orm-jakarta-batch/core/src/test/java/org/hibernate/search/jakarta/batch/core/massindexing/util/impl/SerializationUtilTest.java +++ b/mapper/orm-jakarta-batch/core/src/test/java/org/hibernate/search/jakarta/batch/core/massindexing/util/impl/SerializationUtilTest.java @@ -11,54 +11,54 @@ import org.hibernate.search.util.common.SearchException; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Mincong Huang */ -public class SerializationUtilTest { +class SerializationUtilTest { @Test - public void serializeAndDeserialize() throws Exception { + void serializeAndDeserialize() throws Exception { Object i = SerializationUtil.deserialize( SerializationUtil.serialize( 1 ) ); assertThat( (Integer) i ).isEqualTo( 1 ); } @Test - public void deserializeInt_fromInt() throws Exception { + void deserializeInt_fromInt() throws Exception { int i = SerializationUtil.parseIntegerParameter( "My parameter", "1" ); assertThat( i ).isEqualTo( 1 ); } @Test - public void deserializeInt_fromDouble() throws Exception { + void deserializeInt_fromDouble() throws Exception { assertThatThrownBy( () -> SerializationUtil.parseIntegerParameter( "My parameter", "1.0" ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Invalid value for job parameter 'My parameter': '1.0'." ); } @Test - public void deserializeInt_fromOther() throws Exception { + void deserializeInt_fromOther() throws Exception { assertThatThrownBy( () -> SerializationUtil.parseIntegerParameter( "My parameter", "foo" ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Invalid value for job parameter 'My parameter': 'foo'." ); } @Test - public void deserializeInt_missing() throws Exception { + void deserializeInt_missing() throws Exception { assertThatThrownBy( () -> SerializationUtil.parseIntegerParameter( "My parameter", null ) ) .isInstanceOf( SearchException.class ) .hasMessageContaining( "Invalid value for job parameter 'My parameter': 'null'." ); } @Test - public void deserializeInt_defaultValue() throws Exception { + void deserializeInt_defaultValue() throws Exception { int i = SerializationUtil.parseIntegerParameterOptional( "My parameter", null, 1 ); assertThat( i ).isEqualTo( 1 ); } @Test - public void deserializeBoolean_fromLowerCase() throws Exception { + void deserializeBoolean_fromLowerCase() throws Exception { boolean t = SerializationUtil.parseBooleanParameterOptional( "My parameter 1", "true", false ); boolean f = SerializationUtil.parseBooleanParameterOptional( "My parameter 2", "false", true ); assertThat( t ).isTrue(); @@ -66,7 +66,7 @@ public void deserializeBoolean_fromLowerCase() throws Exception { } @Test - public void deserializeBoolean_fromUpperCase() throws Exception { + void deserializeBoolean_fromUpperCase() throws Exception { boolean t = SerializationUtil.parseBooleanParameterOptional( "My parameter 1", "TRUE", false ); boolean f = SerializationUtil.parseBooleanParameterOptional( "My parameter 2", "FALSE", true ); assertThat( t ).isTrue(); @@ -74,7 +74,7 @@ public void deserializeBoolean_fromUpperCase() throws Exception { } @Test - public void deserializeBoolean_fromIrregularCase() throws Exception { + void deserializeBoolean_fromIrregularCase() throws Exception { boolean t = SerializationUtil.parseBooleanParameterOptional( "My parameter 1", "TruE", false ); boolean f = SerializationUtil.parseBooleanParameterOptional( "My parameter 2", "FalSe", true ); assertThat( t ).as( "Case should be ignored." ).isTrue(); @@ -82,7 +82,7 @@ public void deserializeBoolean_fromIrregularCase() throws Exception { } @Test - public void deserializeBoolean_fromMissing() throws Exception { + void deserializeBoolean_fromMissing() throws Exception { boolean t = SerializationUtil.parseBooleanParameterOptional( "My parameter 1", null, true ); boolean f = SerializationUtil.parseBooleanParameterOptional( "My parameter 2", null, false ); assertThat( t ).as( "Default value should be returned." ).isTrue(); @@ -90,7 +90,7 @@ public void deserializeBoolean_fromMissing() throws Exception { } @Test - public void deserializeBoolean_fromOthers() throws Exception { + void deserializeBoolean_fromOthers() throws Exception { for ( String value : new String[] { "", "0", "1", "t", "f" } ) { assertThatThrownBy( () -> SerializationUtil.parseBooleanParameterOptional( "My parameter", value, true ) ) .isInstanceOf( SearchException.class ) diff --git a/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/HibernateOrmExtensionTest.java b/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/HibernateOrmExtensionTest.java index 1a9e4eb0e39..91ae2d750a0 100644 --- a/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/HibernateOrmExtensionTest.java +++ b/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/HibernateOrmExtensionTest.java @@ -29,18 +29,17 @@ import org.hibernate.search.mapper.pojo.bridge.runtime.spi.BridgeMappingContext; import org.hibernate.search.mapper.pojo.bridge.runtime.spi.BridgeSessionContext; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -public class HibernateOrmExtensionTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) +class HibernateOrmExtensionTest { @Mock private HibernateOrmMappingContextMock mappingContext; @@ -48,7 +47,7 @@ public class HibernateOrmExtensionTest { private HibernateOrmSessionContextMock sessionContext; @Test - public void identifierBridge() { + void identifierBridge() { IdentifierBridgeToDocumentIdentifierContext toDocumentContext = new IdentifierBridgeToDocumentIdentifierContextImpl( mappingContext ); assertThat( toDocumentContext.extension( HibernateOrmExtension.get() ) ).isSameAs( mappingContext ); @@ -59,25 +58,25 @@ public void identifierBridge() { } @Test - public void routingBridge() { + void routingBridge() { RoutingBridgeRouteContext context = new SessionBasedBridgeOperationContext( sessionContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( sessionContext ); } @Test - public void typeBridge() { + void typeBridge() { TypeBridgeWriteContext context = new SessionBasedBridgeOperationContext( sessionContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( sessionContext ); } @Test - public void propertyBridge() { + void propertyBridge() { PropertyBridgeWriteContext context = new SessionBasedBridgeOperationContext( sessionContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( sessionContext ); } @Test - public void valueBridge() { + void valueBridge() { ValueBridgeToIndexedValueContext toIndexedValueContext = new ValueBridgeToIndexedValueContextImpl( mappingContext ); assertThat( toIndexedValueContext.extension( HibernateOrmExtension.get() ) ).isSameAs( mappingContext ); @@ -87,7 +86,7 @@ public void valueBridge() { @Test @SuppressWarnings("deprecation") - public void toDocumentFieldValueConverter() { + void toDocumentFieldValueConverter() { org.hibernate.search.engine.backend.types.converter.runtime.ToDocumentFieldValueConvertContext context = new ToDocumentValueConvertContextImpl( mappingContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( mappingContext ); @@ -95,14 +94,14 @@ public void toDocumentFieldValueConverter() { @Test @SuppressWarnings("deprecation") - public void toDocumentValueConverter() { + void toDocumentValueConverter() { ToDocumentValueConvertContext context = new ToDocumentValueConvertContextImpl( mappingContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( mappingContext ); } @Test @SuppressWarnings("deprecation") - public void fromDocumentFieldValueConverter() { + void fromDocumentFieldValueConverter() { org.hibernate.search.engine.backend.types.converter.runtime.FromDocumentFieldValueConvertContext context = new FromDocumentValueConvertContextImpl( sessionContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( sessionContext ); @@ -110,7 +109,7 @@ public void fromDocumentFieldValueConverter() { @Test @SuppressWarnings("deprecation") - public void fromDocumentValueConverter() { + void fromDocumentValueConverter() { FromDocumentValueConvertContext context = new FromDocumentValueConvertContextImpl( sessionContext ); assertThat( context.extension( HibernateOrmExtension.get() ) ).isSameAs( sessionContext ); } diff --git a/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/AbstractHibernateOrmBootstrapIntrospectorPerReflectionStrategyTest.java b/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/AbstractHibernateOrmBootstrapIntrospectorPerReflectionStrategyTest.java index 9dd4e458c5d..1a8f646ec34 100644 --- a/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/AbstractHibernateOrmBootstrapIntrospectorPerReflectionStrategyTest.java +++ b/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/AbstractHibernateOrmBootstrapIntrospectorPerReflectionStrategyTest.java @@ -22,35 +22,30 @@ import org.hibernate.search.util.common.impl.Closer; import org.hibernate.search.util.common.reflect.spi.ValueHandleFactory; -import org.junit.After; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.provider.Arguments; -@RunWith(Parameterized.class) public abstract class AbstractHibernateOrmBootstrapIntrospectorPerReflectionStrategyTest { - @Parameterized.Parameters(name = "Reflection strategy = {0}") - public static List data() { - return Arrays.asList( new Object[][] { - { ValueHandleFactory.usingJavaLangReflect() }, - { ValueHandleFactory.usingMethodHandle( MethodHandles.publicLookup() ) } - } ); + public static List params() { + return Arrays.asList( + Arguments.of( ValueHandleFactory.usingJavaLangReflect() ), + Arguments.of( ValueHandleFactory.usingMethodHandle( MethodHandles.publicLookup() ) ) + ); } private final List toClose = new ArrayList<>(); - @Parameterized.Parameter - public ValueHandleFactory valueHandleFactory; - - @After - public void cleanup() throws Exception { + @AfterEach + void cleanup() throws Exception { try ( Closer closer = new Closer<>() ) { closer.pushAll( AutoCloseable::close, toClose ); } } @SuppressWarnings("deprecation") // There's no other way to access the reflection manager - final HibernateOrmBootstrapIntrospector createIntrospector(Class... entityClasses) { + final HibernateOrmBootstrapIntrospector createIntrospector(ValueHandleFactory valueHandleFactory, + Class... entityClasses) { StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(); // Some properties that are not relevant to our test, but necessary to create the Metadata registryBuilder.applySetting( AvailableSettings.DIALECT, H2Dialect.class ); diff --git a/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBootstrapIntrospectorAccessTypeTest.java b/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBootstrapIntrospectorAccessTypeTest.java index 2b3e1a6ca2c..b7836520f2a 100644 --- a/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBootstrapIntrospectorAccessTypeTest.java +++ b/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBootstrapIntrospectorAccessTypeTest.java @@ -7,7 +7,7 @@ package org.hibernate.search.mapper.orm.model.impl; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.fail; import java.util.List; import java.util.Map; @@ -26,117 +26,138 @@ import jakarta.persistence.Transient; import org.hibernate.search.mapper.pojo.model.spi.PojoRawTypeModel; +import org.hibernate.search.util.common.reflect.spi.ValueHandleFactory; import org.hibernate.search.util.common.reflect.spi.ValueReadHandle; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -public class HibernateOrmBootstrapIntrospectorAccessTypeTest +class HibernateOrmBootstrapIntrospectorAccessTypeTest extends AbstractHibernateOrmBootstrapIntrospectorPerReflectionStrategyTest { - @Test - public void entity_defaultFieldAccess() { - HibernateOrmBootstrapIntrospector introspector = createIntrospector( EntityWithDefaultFieldAccess.class ); + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void entity_defaultFieldAccess(ValueHandleFactory valueHandleFactory) { + HibernateOrmBootstrapIntrospector introspector = createIntrospector( + valueHandleFactory, EntityWithDefaultFieldAccess.class ); testEntityWithDefaultFieldAccess( introspector ); } - @Test - public void entity_defaultMethodAccess() { - HibernateOrmBootstrapIntrospector introspector = createIntrospector( EntityWithDefaultMethodAccess.class ); + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void entity_defaultMethodAccess(ValueHandleFactory valueHandleFactory) { + HibernateOrmBootstrapIntrospector introspector = createIntrospector( + valueHandleFactory, EntityWithDefaultMethodAccess.class ); testEntityWithDefaultMethodAccess( introspector ); } - @Test - public void embeddedId_defaultFieldAccess() { - HibernateOrmBootstrapIntrospector introspector = createIntrospector( EntityWithEmbeddedIdWithDefaultFieldAccess.class ); + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddedId_defaultFieldAccess(ValueHandleFactory valueHandleFactory) { + HibernateOrmBootstrapIntrospector introspector = createIntrospector( + valueHandleFactory, EntityWithEmbeddedIdWithDefaultFieldAccess.class ); testEmbeddableWithDefaultFieldAccess( introspector ); } - @Test - public void embeddedId_defaultMethodAccess() { - HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddedIdWithDefaultMethodAccess.class ); + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddedId_defaultMethodAccess(ValueHandleFactory valueHandleFactory) { + HibernateOrmBootstrapIntrospector introspector = createIntrospector( + valueHandleFactory, EntityWithEmbeddedIdWithDefaultMethodAccess.class ); testEmbeddableWithDefaultMethodAccess( introspector ); } - @Test - public void embedded_defaultFieldAccess() { - HibernateOrmBootstrapIntrospector introspector = createIntrospector( EntityWithEmbedded.class ); + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embedded_defaultFieldAccess(ValueHandleFactory valueHandleFactory) { + HibernateOrmBootstrapIntrospector introspector = createIntrospector( valueHandleFactory, EntityWithEmbedded.class ); testEmbeddableWithDefaultFieldAccess( introspector ); } - @Test - public void embedded_defaultMethodAccess() { - HibernateOrmBootstrapIntrospector introspector = createIntrospector( EntityWithEmbedded.class ); + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embedded_defaultMethodAccess(ValueHandleFactory valueHandleFactory) { + HibernateOrmBootstrapIntrospector introspector = createIntrospector( valueHandleFactory, EntityWithEmbedded.class ); testEmbeddableWithDefaultMethodAccess( introspector ); } - @Test - public void embeddableElementCollection_defaultFieldAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableElementCollection_defaultFieldAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableElementCollection.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableElementCollection.class ); testEmbeddableWithDefaultFieldAccess( introspector ); } - @Test - public void embeddableElementCollection_defaultMethodAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableElementCollection_defaultMethodAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableElementCollection.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableElementCollection.class ); testEmbeddableWithDefaultMethodAccess( introspector ); } - @Test - public void embeddableAssociationMapKey_defaultFieldAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableAssociationMapKey_defaultFieldAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableAssociationMapKey.class, OtherEntity.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableAssociationMapKey.class, OtherEntity.class ); testEmbeddableWithDefaultFieldAccess( introspector ); } - @Test - public void embeddableAssociationMapKey_defaultMethodAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableAssociationMapKey_defaultMethodAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableAssociationMapKey.class, OtherEntity.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableAssociationMapKey.class, OtherEntity.class ); testEmbeddableWithDefaultMethodAccess( introspector ); } - @Test - public void embeddableAssociationMapValue_defaultFieldAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableAssociationMapValue_defaultFieldAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableAssociationMapValue.class, OtherEntity.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableAssociationMapValue.class, OtherEntity.class ); testEmbeddableWithDefaultFieldAccess( introspector ); } - @Test - public void embeddableAssociationMapValue_defaultMethodAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableAssociationMapValue_defaultMethodAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableAssociationMapValue.class, OtherEntity.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableAssociationMapValue.class, OtherEntity.class ); testEmbeddableWithDefaultMethodAccess( introspector ); } - @Test - public void embeddableElementCollectionMapKey_defaultFieldAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableElementCollectionMapKey_defaultFieldAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableElementCollectionMapKey.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableElementCollectionMapKey.class ); testEmbeddableWithDefaultFieldAccess( introspector ); } - @Test - public void embeddableElementCollectionMapKey_defaultMethodAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableElementCollectionMapKey_defaultMethodAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableElementCollectionMapKey.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableElementCollectionMapKey.class ); testEmbeddableWithDefaultMethodAccess( introspector ); } - @Test - public void embeddableElementCollectionMapValue_defaultFieldAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableElementCollectionMapValue_defaultFieldAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableElementCollectionMapValue.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableElementCollectionMapValue.class ); testEmbeddableWithDefaultFieldAccess( introspector ); } - @Test - public void embeddableElementCollectionMapValue_defaultMethodAccess() { + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void embeddableElementCollectionMapValue_defaultMethodAccess(ValueHandleFactory valueHandleFactory) { HibernateOrmBootstrapIntrospector introspector = - createIntrospector( EntityWithEmbeddableElementCollectionMapValue.class ); + createIntrospector( valueHandleFactory, EntityWithEmbeddableElementCollectionMapValue.class ); testEmbeddableWithDefaultMethodAccess( introspector ); } diff --git a/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBootstrapIntrospectorAnnotationReadingTest.java b/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBootstrapIntrospectorAnnotationReadingTest.java index 8f43e794209..ae983899701 100644 --- a/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBootstrapIntrospectorAnnotationReadingTest.java +++ b/mapper/orm/src/test/java/org/hibernate/search/mapper/orm/model/impl/HibernateOrmBootstrapIntrospectorAnnotationReadingTest.java @@ -17,16 +17,20 @@ import org.hibernate.search.mapper.pojo.model.spi.PojoPropertyModel; import org.hibernate.search.mapper.pojo.model.spi.PojoRawTypeModel; import org.hibernate.search.util.common.reflect.spi.AnnotationHelper; +import org.hibernate.search.util.common.reflect.spi.ValueHandleFactory; import org.hibernate.search.util.impl.test.annotation.TestForIssue; -import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -public class HibernateOrmBootstrapIntrospectorAnnotationReadingTest +class HibernateOrmBootstrapIntrospectorAnnotationReadingTest extends AbstractHibernateOrmBootstrapIntrospectorPerReflectionStrategyTest { - @Test - public void singleAnnotation() { - HibernateOrmBootstrapIntrospector introspector = createIntrospector( EntityWithSingleFieldAnnotation.class ); + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") + void singleAnnotation(ValueHandleFactory valueHandleFactory) { + HibernateOrmBootstrapIntrospector introspector = createIntrospector( + valueHandleFactory, EntityWithSingleFieldAnnotation.class ); AnnotationHelper annotationHelper = new AnnotationHelper( introspector.annotationValueHandleFactory() ); PojoRawTypeModel typeModel = @@ -44,10 +48,12 @@ public void singleAnnotation() { ); } - @Test + @ParameterizedTest(name = "Reflection strategy = {0}") + @MethodSource("params") @TestForIssue(jiraKey = "HSEARCH-3614") - public void repeatedAnnotation() { - HibernateOrmBootstrapIntrospector introspector = createIntrospector( EntityWithRepeatedFieldAnnotation.class ); + void repeatedAnnotation(ValueHandleFactory valueHandleFactory) { + HibernateOrmBootstrapIntrospector introspector = createIntrospector( + valueHandleFactory, EntityWithRepeatedFieldAnnotation.class ); AnnotationHelper annotationHelper = new AnnotationHelper( introspector.annotationValueHandleFactory() ); PojoRawTypeModel typeModel = diff --git a/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/automaticindexing/building/impl/PojoAssociationPathInverterTest.java b/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/automaticindexing/building/impl/PojoAssociationPathInverterTest.java index 713be356803..37a4b565011 100644 --- a/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/automaticindexing/building/impl/PojoAssociationPathInverterTest.java +++ b/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/automaticindexing/building/impl/PojoAssociationPathInverterTest.java @@ -29,20 +29,19 @@ import org.hibernate.search.mapper.pojo.model.spi.PojoTypeModel; import org.hibernate.search.util.common.SearchException; -import org.junit.Rule; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +@MockitoSettings(strictness = Strictness.STRICT_STUBS) +@ExtendWith(MockitoExtension.class) @SuppressWarnings({ "unchecked", "rawtypes" }) -public class PojoAssociationPathInverterTest { - - @Rule - public final MockitoRule mockito = MockitoJUnit.rule().strictness( Strictness.STRICT_STUBS ); +class PojoAssociationPathInverterTest { @Mock private PojoTypeAdditionalMetadataProvider typeAdditionalMetadataProviderMock; @@ -50,7 +49,7 @@ public class PojoAssociationPathInverterTest { private ContainerExtractorBinder extractorBinderMock; @Test - public void detectInfiniteRecursion() { + void detectInfiniteRecursion() { String originalSidePropertyName = "originalSideProperty"; String inverseSideProperty1Name = "inverseSideProperty1"; String inverseSideProperty2Name = "inverseSideProperty2"; diff --git a/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/mapping/definition/annotation/processing/spi/BuiltinAnnotationsTest.java b/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/mapping/definition/annotation/processing/spi/BuiltinAnnotationsTest.java index 5ee64f9261d..06405aa252c 100644 --- a/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/mapping/definition/annotation/processing/spi/BuiltinAnnotationsTest.java +++ b/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/mapping/definition/annotation/processing/spi/BuiltinAnnotationsTest.java @@ -17,18 +17,18 @@ import org.hibernate.search.util.common.jar.impl.JandexUtils; import org.hibernate.search.util.impl.test.jar.JandexTestUtils; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.jboss.jandex.DotName; import org.jboss.jandex.Index; -public class BuiltinAnnotationsTest { +class BuiltinAnnotationsTest { private static Index pojoMapperBaseIndex; - @BeforeClass - public static void index() throws IOException { + @BeforeAll + static void index() throws IOException { pojoMapperBaseIndex = readOrBuildIndex( codeSourceLocation( BuiltinAnnotations.class ) .orElseThrow( () -> new AssertionFailure( "Could not find hibernate-search-mapper-pojo-base JAR?" ) ) @@ -36,12 +36,12 @@ public static void index() throws IOException { } @Test - public void testRootMapping() { + void testRootMapping() { assertThat( pojoMapperBaseIndex.getClassByName( BuiltinAnnotations.ROOT_MAPPING ) ).isNotNull(); } @Test - public void testNoMissingRootMappingAnnotation() { + void testNoMissingRootMappingAnnotation() { Set rootMappingAnnotatedAnnotations = JandexUtils.findAnnotatedAnnotationsAndContaining( pojoMapperBaseIndex, BuiltinAnnotations.ROOT_MAPPING ); diff --git a/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/model/path/PojoModelPathTest.java b/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/model/path/PojoModelPathTest.java index 28bd7986ff3..cf949fa71f6 100644 --- a/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/model/path/PojoModelPathTest.java +++ b/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/model/path/PojoModelPathTest.java @@ -18,12 +18,12 @@ import org.hibernate.search.mapper.pojo.extractor.mapping.programmatic.ContainerExtractorPath; import org.hibernate.search.util.common.SearchException; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class PojoModelPathTest { +class PojoModelPathTest { @Test - public void ofProperty() { + void ofProperty() { assertThat( PojoModelPath.ofProperty( "foo" ) ) .satisfies( isPath( "foo" ) ); @@ -44,7 +44,7 @@ public void ofProperty() { } @Test - public void ofValue_property() { + void ofValue_property() { assertThat( PojoModelPath.ofValue( "foo" ) ) .satisfies( isPath( "foo", ContainerExtractorPath.defaultExtractors() ) ); @@ -60,7 +60,7 @@ public void ofValue_property() { } @Test - public void ofValue_propertyAndContainerExtractorPath() { + void ofValue_propertyAndContainerExtractorPath() { assertThat( PojoModelPath.ofValue( "foo", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.MAP_KEY ) ) ) .satisfies( isPath( "foo", ContainerExtractorPath.explicitExtractor( BuiltinContainerExtractors.MAP_KEY ) ) ); @@ -84,7 +84,7 @@ public void ofValue_propertyAndContainerExtractorPath() { } @Test - public void parse() { + void parse() { assertThat( PojoModelPath.parse( "foo" ) ) .satisfies( isPath( "foo", ContainerExtractorPath.defaultExtractors() @@ -118,7 +118,7 @@ public void parse() { } @Test - public void builder() { + void builder() { PojoModelPath.Builder builder = PojoModelPath.builder(); builder.property( "foo" ).value( BuiltinContainerExtractors.COLLECTION ) .property( "bar" ).valueWithoutExtractors() @@ -153,7 +153,7 @@ public void builder() { } @Test - public void builder_missingContainerExtractorPath_middle() { + void builder_missingContainerExtractorPath_middle() { PojoModelPath.Builder builder = PojoModelPath.builder(); builder.property( "foo" ).property( "bar" ).value( BuiltinContainerExtractors.MAP_KEY ); assertThat( builder.toValuePath() ) @@ -164,7 +164,7 @@ public void builder_missingContainerExtractorPath_middle() { } @Test - public void builder_missingContainerExtractorPath_end() { + void builder_missingContainerExtractorPath_end() { PojoModelPath.Builder builder = PojoModelPath.builder(); builder.property( "foo" ).value( BuiltinContainerExtractors.COLLECTION ).property( "bar" ); assertThat( builder.toValuePath() ) @@ -183,7 +183,7 @@ public void builder_missingContainerExtractorPath_end() { } @Test - public void builder_missingPropertyName() { + void builder_missingPropertyName() { assertThat( PojoModelPath.builder().toValuePathOrNull() ).isNull(); assertThat( PojoModelPath.builder().toPropertyPathOrNull() ).isNull(); @@ -222,7 +222,7 @@ public void builder_missingPropertyName() { } @Test - public void builder_chainedContainerExtractors() { + void builder_chainedContainerExtractors() { PojoModelPath.Builder builder = PojoModelPath.builder(); builder.property( "foo" ).value( BuiltinContainerExtractors.COLLECTION ).value( BuiltinContainerExtractors.ITERABLE ) .property( "bar" ).value( BuiltinContainerExtractors.MAP_KEY ); @@ -237,7 +237,7 @@ public void builder_chainedContainerExtractors() { } @Test - public void builder_chainedContainerExtractors_defaultExtractors() { + void builder_chainedContainerExtractors_defaultExtractors() { assertThat( PojoModelPath.builder().property( "foo" ) .valueWithoutExtractors().valueWithDefaultExtractors() .toValuePath() @@ -265,7 +265,7 @@ public void builder_chainedContainerExtractors_defaultExtractors() { } @Test - public void relativize_correctPrefix() { + void relativize_correctPrefix() { assertThat( PojoModelPath.builder() .property( "foo" ) .property( "bar" ) @@ -342,7 +342,7 @@ public void relativize_correctPrefix() { } @Test - public void relativize_self() { + void relativize_self() { assertThat( PojoModelPath.builder() .property( "foo" ) .toValuePath() @@ -378,7 +378,7 @@ public void relativize_self() { } @Test - public void relativize_unrelated() { + void relativize_unrelated() { assertThat( PojoModelPath.builder() .property( "foo" ) .toValuePath() diff --git a/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/model/typepattern/impl/TypePatternMatcherFactoryTest.java b/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/model/typepattern/impl/TypePatternMatcherFactoryTest.java index 9b612672134..db2d8992631 100644 --- a/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/model/typepattern/impl/TypePatternMatcherFactoryTest.java +++ b/mapper/pojo-base/src/test/java/org/hibernate/search/mapper/pojo/model/typepattern/impl/TypePatternMatcherFactoryTest.java @@ -24,17 +24,17 @@ import org.hibernate.search.util.impl.test.reflect.WildcardTypeCapture; import org.hibernate.search.util.impl.test.reflect.WildcardTypeCapture.Of; -import org.junit.Test; +import org.junit.jupiter.api.Test; @SuppressWarnings({ "unchecked", "rawtypes" }) // Raw types are the only way to mock parameterized types -public class TypePatternMatcherFactoryTest { +class TypePatternMatcherFactoryTest { private final PojoBootstrapIntrospector introspectorMock = mock( PojoBootstrapIntrospector.class ); private final TypePatternMatcherFactory factory = new TypePatternMatcherFactory( introspectorMock ); @Test - public void exactType() { + void exactType() { PojoRawTypeModel typeToMatchMock = mock( PojoRawTypeModel.class ); PojoTypeModel typeToInspectMock = mock( PojoTypeModel.class ); PojoRawTypeModel typeToInspectRawTypeMock = mock( PojoRawTypeModel.class ); @@ -81,7 +81,7 @@ public void exactType() { * Useful for bridge mapping in particular. */ @Test - public void concreteEnumType() { + void concreteEnumType() { PojoRawTypeModel enumTypeMock = mock( PojoRawTypeModel.class ); PojoTypeModel typeToInspectMock = mock( PojoTypeModel.class ); PojoRawTypeModel typeToInspectRawTypeMock = mock( PojoRawTypeModel.class ); @@ -124,7 +124,7 @@ public void concreteEnumType() { } @Test - public void wildcardType() { + void wildcardType() { assertThatThrownBy( () -> factory.createExtractingMatcher( new WildcardTypeCapture>() {}.getType(), String.class @@ -133,7 +133,7 @@ public void wildcardType() { } @Test - public void typeVariable() { + void typeVariable() { // Must put this here, not in the lambda, otherwise the generated type is a bit different. Type type = new TypeCapture() {}.getType(); assertThatThrownBy( () -> factory.createExtractingMatcher( @@ -144,7 +144,7 @@ public void typeVariable() { } @Test - public void rawSuperType() { + void rawSuperType() { PojoRawTypeModel typeToMatchMock = mock( PojoRawTypeModel.class ); PojoRawTypeModel resultTypeMock = mock( PojoRawTypeModel.class ); PojoTypeModel typeToInspectMock = mock( PojoTypeModel.class ); @@ -183,7 +183,7 @@ public void rawSuperType() { } @Test - public void rawSuperType_resultIsTypeVariable() { + void rawSuperType_resultIsTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( String.class, new TypeCapture() {}.getType() @@ -192,7 +192,7 @@ public void rawSuperType_resultIsTypeVariable() { } @Test - public void rawSuperType_resultIsWildcard() { + void rawSuperType_resultIsWildcard() { assertThatThrownBy( () -> factory.createExtractingMatcher( String.class, new WildcardTypeCapture>() {}.getType() @@ -201,7 +201,7 @@ public void rawSuperType_resultIsWildcard() { } @Test - public void rawSuperType_resultIsParameterized() { + void rawSuperType_resultIsParameterized() { assertThatThrownBy( () -> factory.createExtractingMatcher( String.class, new TypeCapture>() {}.getType() @@ -210,7 +210,7 @@ public void rawSuperType_resultIsParameterized() { } @Test - public void nonGenericArrayElement() { + void nonGenericArrayElement() { PojoRawTypeModel typeToMatchMock = mock( PojoRawTypeModel.class ); PojoRawTypeModel resultTypeMock = mock( PojoRawTypeModel.class ); PojoTypeModel typeToInspectMock = mock( PojoTypeModel.class ); @@ -243,7 +243,7 @@ public void nonGenericArrayElement() { } @Test - public void genericArrayElement() { + void genericArrayElement() { PojoTypeModel typeToInspectMock = mock( PojoTypeModel.class ); PojoTypeModel resultTypeMock = mock( PojoTypeModel.class ); @@ -272,7 +272,7 @@ public void genericArrayElement() { } @Test - public > void genericArrayElement_boundedTypeVariable() { + > void genericArrayElement_boundedTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture() {}.getType(), new TypeCapture() {}.getType() @@ -281,7 +281,7 @@ public > void genericArrayElement_boundedTypeVariable() { } @Test - public void genericArrayElement_multiBoundedTypeVariable() { + void genericArrayElement_multiBoundedTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture() {}.getType(), new TypeCapture() {}.getType() @@ -290,7 +290,7 @@ public void genericArrayElement_multiBoundedTy } @Test - public void genericArrayElement_resultIsRawType() { + void genericArrayElement_resultIsRawType() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture() {}.getType(), Object.class @@ -299,7 +299,7 @@ public void genericArrayElement_resultIsRawType() { } @Test - public void genericArrayElement_resultIsDifferentTypeArgument() { + void genericArrayElement_resultIsDifferentTypeArgument() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture() {}.getType(), new TypeCapture() {}.getType() @@ -308,7 +308,7 @@ public void genericArrayElement_resultIsDifferentTypeArgument() { } @Test - public void parameterizedType() { + void parameterizedType() { PojoTypeModel typeToInspectMock = mock( PojoTypeModel.class ); PojoTypeModel resultTypeMock = mock( PojoTypeModel.class ); @@ -337,7 +337,7 @@ public void parameterizedType() { } @Test - public void parameterizedType_upperBoundedWildcard() { + void parameterizedType_upperBoundedWildcard() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture>() {}.getType(), new TypeCapture() {}.getType() @@ -346,7 +346,7 @@ public void parameterizedType_upperBoundedWildcard() { } @Test - public void parameterizedType_lowerBoundedWildcard() { + void parameterizedType_lowerBoundedWildcard() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture>() {}.getType(), new TypeCapture() {}.getType() @@ -355,7 +355,7 @@ public void parameterizedType_lowerBoundedWildcard() { } @Test - public void parameterizedType_onlyWildcards() { + void parameterizedType_onlyWildcards() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture>() {}.getType(), new TypeCapture() {}.getType() @@ -364,7 +364,7 @@ public void parameterizedType_onlyWildcards() { } @Test - public void parameterizedType_rawType() { + void parameterizedType_rawType() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture>() {}.getType(), new TypeCapture() {}.getType() @@ -373,7 +373,7 @@ public void parameterizedType_rawType() { } @Test - public > void parameterizedType_boundedTypeVariable() { + > void parameterizedType_boundedTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture>() {}.getType(), new TypeCapture() {}.getType() @@ -382,7 +382,7 @@ public > void parameterizedType_boundedTypeVariable() { } @Test - public void parameterizedType_multiBoundedTypeVariable() { + void parameterizedType_multiBoundedTypeVariable() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture>() {}.getType(), new TypeCapture() {}.getType() @@ -391,7 +391,7 @@ public void parameterizedType_multiBoundedType } @Test - public void parameterizedType_multipleTypeVariables() { + void parameterizedType_multipleTypeVariables() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture>() {}.getType(), new TypeCapture() {}.getType() @@ -400,7 +400,7 @@ public void parameterizedType_multipleTypeVariables() { } @Test - public void parameterizedType_resultIsRawType() { + void parameterizedType_resultIsRawType() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture>() {}.getType(), Object.class @@ -409,7 +409,7 @@ public void parameterizedType_resultIsRawType() { } @Test - public void parameterizedType_resultIsDifferentTypeArgument() { + void parameterizedType_resultIsDifferentTypeArgument() { assertThatThrownBy( () -> factory.createExtractingMatcher( new TypeCapture>() {}.getType(), new TypeCapture() {}.getType() diff --git a/pom.xml b/pom.xml index 1e03e21630e..c0514f3039f 100644 --- a/pom.xml +++ b/pom.xml @@ -831,15 +831,6 @@ ${surefire.reportNameSuffix} - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} - - - org.apache.maven.surefire - surefire-junit47 - ${version.surefire.plugin} -