Class GeneFactory

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

@Component public class GeneFactory extends Object
Typed factory for persistent Gene test fixtures.

Phase 3 replacement for PersistentDummyObjectHelper.getTestPersistentGene(...). Produces a persistent Gene on a seeded Taxon (default: mouse), with an NCBI id in the synthetic 500k+ range, optionally accompanied by GeneProducts.

Usage:

  // Default: mouse gene, random name, synthetic NCBI id, no products
  Gene g = geneFactory.builder().build();

  // Human gene with a specific official symbol
  Gene g = geneFactory.builder()
               .withTaxon(humanTaxon)
               .withOfficialSymbol("BRCA1")
               .build();

  // Mouse gene with 3 attached gene products
  Gene g = geneFactory.builder().withGeneProducts(3).build();

  // Fully specified
  Gene g = geneFactory.builder()
               .withName("brca1_test")
               .withOfficialSymbol("BRCA1")
               .withOfficialName("breast cancer 1")
               .withNcbiId(672)
               .withTaxon(taxonFactory.human())
               .build();

Design notes (HB6-relevant):

  • build() persists the gene via GeneService#create(Gene) so ACL / audit listeners fire on the production code path.
  • GeneProducts are attached via gene.getProducts().add(gp) (mutate, don't replace) before the gene persist; the Gene→GeneProduct cascade handles them.
  • Taxon is resolved via TaxonFactory so it comes from the seeded init-data.sql rows (never fabricated transient). Default taxon is mouse; override with GeneFactory.GeneBuilder.withTaxon(Taxon).
  • Synthetic NCBI ids land in [500_000, 1_500_000) so they never collide with real assignments. Override with GeneFactory.GeneBuilder.withNcbiId(int) if a specific value is needed.
Author:
Phase 3 (Vision section 3 - test-fixture rewrite)
  • Constructor Details

    • GeneFactory

      public GeneFactory()
  • Method Details