Class BioMaterialFactory
java.lang.Object
ubic.gemma.core.util.test.fixture.BioMaterialFactory
Typed factory for persistent
BioMaterial test fixtures.
Phase 3 replacement for
PersistentDummyObjectHelper.getTestPersistentBioMaterial(...). Same
shape as ExperimentFactory: fluent builder, sensible defaults,
persists through the production service so the ACL-creation listener fires.
var bm = bioMaterialFactory.build(); var bm = bioMaterialFactory.withTaxon(rat).build(); var child = bioMaterialFactory.withSourceBioMaterial(parent).build(); var bm = bioMaterialFactory.withExternalAccession().build();
Design notes (HB6-relevant):
build()persists viaSecurableBaseImmutableService.create(BioMaterial).- Taxon is resolved from
init-data.sql-seeded rows viaTaxonService.findByCommonName(String)— never fabricated transient. - If a source
BioMaterialis supplied, its id is required (i.e. it must be persistent already); the factory does not silently cascade-persist a transient parent. - The optional external accession resolves the
ExternalDatabasethrough the service rather than instantiating it transient — the same pattern asExperimentFactory. - The builder is single-use;
withXxxreturns the factory itself (not a separate Builder type) because BM construction is a one-shot and an extra Builder class would be noise. Each call tobuild()produces a fresh persistent BM but reuses any sticky configuration — so prefer building each BM with a freshbioMaterialFactory.withXxx(...).build()chain.
- Author:
- Phase 3 (Vision §3 — test-fixture rewrite)
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Convenience: build with all defaults.builder()Start building aBioMaterialwith defaults: mouse taxon, no source biomaterial, no external accession, auto-generated name.Convenience: attach a GEO external accession (defaults elsewhere).Convenience for the common "specify name, defaults elsewhere" case.withSourceBioMaterial(BioMaterial parent) Convenience for the common "specify parent, defaults elsewhere" case.Convenience for the common "specify taxon, defaults elsewhere" case.
-
Constructor Details
-
BioMaterialFactory
public BioMaterialFactory()
-
-
Method Details
-
builder
Start building aBioMaterialwith defaults: mouse taxon, no source biomaterial, no external accession, auto-generated name. -
build
Convenience: build with all defaults. -
withTaxon
Convenience for the common "specify taxon, defaults elsewhere" case. -
withName
Convenience for the common "specify name, defaults elsewhere" case. -
withSourceBioMaterial
Convenience for the common "specify parent, defaults elsewhere" case. -
withExternalAccession
Convenience: attach a GEO external accession (defaults elsewhere).
-