Class BioMaterialFactory

java.lang.Object
ubic.gemma.core.util.test.fixture.BioMaterialFactory

@Component public class BioMaterialFactory extends Object
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 via SecurableBaseImmutableService.create(BioMaterial).
  • Taxon is resolved from init-data.sql-seeded rows via TaxonService.findByCommonName(String) — never fabricated transient.
  • If a source BioMaterial is 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 ExternalDatabase through the service rather than instantiating it transient — the same pattern as ExperimentFactory.
  • The builder is single-use; withXxx returns 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 to build() produces a fresh persistent BM but reuses any sticky configuration — so prefer building each BM with a fresh bioMaterialFactory.withXxx(...).build() chain.
Author:
Phase 3 (Vision §3 — test-fixture rewrite)
  • Constructor Details

    • BioMaterialFactory

      public BioMaterialFactory()
  • Method Details