Class SearchServiceImplTest

java.lang.Object
ubic.gemma.core.search.SearchServiceImplTest

public class SearchServiceImplTest extends Object
Unit-level smoke tests for SearchServiceImpl.

Validates the Step-5 wiring with an "empty index": all registered SearchSource beans return empty collections, and we assert that:

  1. no exception is thrown,
  2. the resulting SearchService.SearchResultMap is empty,
  3. SearchService.SearchResultMap.getResultTypes() is empty,
  4. VO-conversion bootstrap completes (the ConversionService is 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 Details

    • SearchServiceImplTest

      public SearchServiceImplTest()
  • Method Details

    • setUp

      @BeforeEach public void setUp()
    • searchEmptyIndexReturnsEmptyMap

      @Test public void searchEmptyIndexReturnsEmptyMap()
    • searchEmptyQueryReturnsEmptyMap

      @Test public void searchEmptyQueryReturnsEmptyMap() throws SearchException
      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=STAT5B returned 500 (UnexpectedRollbackException) — an inner converter's LazyInitException marked 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 a TransactionDefinition.PROPAGATION_REQUIRES_NEW sub-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 throws ConversionFailedException (the wrap around LazyInitializationException), SearchServiceImpl.loadValueObjects(Collection) must catch it and fall through to the id-path rather than propagating. This pairs with entityPathTxTemplateUsesRequiresNewAndReadOnly(): 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.