Class SearchServiceImplTest
SearchServiceImpl.
Validates the Step-5 wiring with an "empty index": all registered SearchSource
beans return empty collections, and we assert that:
- no exception is thrown,
- the resulting
SearchService.SearchResultMapis empty, SearchService.SearchResultMap.getResultTypes()is empty,- VO-conversion bootstrap completes (the
ConversionServiceis consulted but no hits are converted because none are returned).
This is the regression bar for "the search subsystem returns harmlessly when the Lucene index has not yet been built." It does not exercise the Hibernate Search 7 backend itself; that lives behind a Spring + JPA boot that the integration tests cover.
- Author:
- paul
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidA DETACHED entity must go straight to the id-path, without attempting the entity path at all: the entity-path converter walks lazy associations, so on a detached entity it can only fail — and before the up-front check, every anonymous /search result did exactly that (sub-transaction, LazyInitException, one retry by the generic retry advice, a WARN, and then the id-path anyway; 6/6 requests in the 2026-08-19 perf baseline).voidBehavioural fallback: when the entity-path converter throwsConversionFailedException(the wrap aroundLazyInitializationException),SearchServiceImpl.loadValueObjects(Collection)must catch it and fall through to the id-path rather than propagating.voidWhen no PlatformTransactionManager is wired (existing unit-test contexts), the entity path falls back to an inline convert.voidPins the sub-transaction template configuration: REQUIRES_NEW + readOnly.voidvoidvoidvoidsetUp()void
-
Constructor Details
-
SearchServiceImplTest
public SearchServiceImplTest()
-
-
Method Details
-
setUp
@BeforeEach public void setUp() -
searchEmptyIndexReturnsEmptyMap
@Test public void searchEmptyIndexReturnsEmptyMap() -
searchEmptyQueryReturnsEmptyMap
- Throws:
SearchException
-
supportedResultTypesIsTheCanonicalEight
@Test public void supportedResultTypesIsTheCanonicalEight() -
loadValueObjectOfEmptyResultListIsEmpty
@Test public void loadValueObjectOfEmptyResultListIsEmpty() -
entityPathTxTemplateUsesRequiresNewAndReadOnly
@Test public void entityPathTxTemplateUsesRequiresNewAndReadOnly()Pins the sub-transaction template configuration: REQUIRES_NEW + readOnly.Regression guard for the 2026-05-27 frink hit where
/search?query=STAT5Breturned 500 (UnexpectedRollbackException) — an inner converter'sLazyInitExceptionmarked the OUTER search transaction rollback-only via the shared-propagation @Transactional advisor, even though the entity-path catch+promote had already produced valid id-path results. Running the brittle convert call in aTransactionDefinition.PROPAGATION_REQUIRES_NEWsub-transaction contains the rollback; this test prevents a future "simplification" from collapsing the sub-txn back into the parent. -
entityPathFailurePromotesToIdPath
@Test public void entityPathFailurePromotesToIdPath()Behavioural fallback: when the entity-path converter throwsConversionFailedException(the wrap aroundLazyInitializationException),SearchServiceImpl.loadValueObjects(Collection)must catch it and fall through to the id-path rather than propagating. This pairs withentityPathTxTemplateUsesRequiresNewAndReadOnly(): REQUIRES_NEW keeps the outer txn clean; this guard ensures the catch+id-promote pipeline is still wired. -
detachedEntitySkipsEntityPathEntirely
@Test public void detachedEntitySkipsEntityPathEntirely()A DETACHED entity must go straight to the id-path, without attempting the entity path at all: the entity-path converter walks lazy associations, so on a detached entity it can only fail — and before the up-front check, every anonymous /search result did exactly that (sub-transaction, LazyInitException, one retry by the generic retry advice, a WARN, and then the id-path anyway; 6/6 requests in the 2026-08-19 perf baseline). Detachment is knowable before converting; this pins that we ask first. -
entityPathFallsBackToInlineWhenNoTxManager
@Test public void entityPathFallsBackToInlineWhenNoTxManager()When no PlatformTransactionManager is wired (existing unit-test contexts), the entity path falls back to an inline convert. The catch+id-promote still applies.
-