Class ExperimentFactory
java.lang.Object
ubic.gemma.core.util.test.fixture.ExperimentFactory
Typed factory for persistent
ExpressionExperiment test fixtures.
This is the Phase 3 replacement for the bulkier
PersistentDummyObjectHelper.getTestPersistentBasicExpressionExperiment(...)
family. It exists to make test fixtures Hibernate-6-safe by construction
and to keep test setup boilerplate down to one line:
var ee = experimentFactory.bulkRna().build(); var ee = experimentFactory.bulkRna().withSamples(50).withArrayDesign(ad).build(); var ee = experimentFactory.singleCell().build();
Design notes (HB6-relevant):
build()persists the experiment viaSecurableBaseImmutableService.create(ExpressionExperiment)so the ACL-creation listener fires through the production code path (mirrors how real EEs are created).- The transient EE is constructed with all associations attached BEFORE
persist. Collections on the entity are mutated via
getXxx().add(...)rather than replaced viasetXxx(new HashSet<>(...)); the latter pattern is the classic HB6PersistentSetreplacement pitfall on managed entities and the habit is enforced here so that future "withXxx().withYyy().postPersistMutation()" extensions remain safe. - Taxa are resolved from
init-data.sql-seeded rows viaTaxonService.findByCommonName(String); the factory never fabricates a transientTaxon(that pattern relied on HB5's loose findOrCreate in the persister and broke in HB6). - External databases (GEO, PubMed) are resolved from
ExternalDatabaseService.findByName(String)for the same reason; only theDatabaseEntrythat links to them is transient. - If no
ArrayDesignis supplied, one is created and persisted up-front throughSecurableBaseImmutableService.create(ArrayDesign)so that bioassays attach to a managed AD.
- Author:
- Phase 3 (Vision §3 — test-fixture rewrite)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder for anExpressionExperiment.static enumModality of the experiment being built. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbulkRna()Start building a bulk-RNA expression experiment.Start building a single-cell expression experiment.
-
Constructor Details
-
ExperimentFactory
public ExperimentFactory()
-
-
Method Details
-
bulkRna
Start building a bulk-RNA expression experiment. Defaults: mouse taxon, 8 samples, freshly-minted single-platform AD with zero composite sequences, one preferred rawQuantitationType. -
singleCell
Start building a single-cell expression experiment. Same defaults asbulkRna()except that the EE is flagged single-cell and no raw bulk QT is added by default. Single-cell vector population is the caller's responsibility (useSingleCellExpressionExperimentServiceafterExperimentFactory.Builder.build()returns).
-