Class GeneFactory
java.lang.Object
ubic.gemma.core.util.test.fixture.GeneFactory
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 viaGeneService#create(Gene)so ACL / audit listeners fire on the production code path.GeneProducts are attached viagene.getProducts().add(gp)(mutate, don't replace) before the gene persist; the Gene→GeneProduct cascade handles them.Taxonis resolved viaTaxonFactoryso it comes from the seededinit-data.sqlrows (never fabricated transient). Default taxon is mouse; override withGeneFactory.GeneBuilder.withTaxon(Taxon).- Synthetic NCBI ids land in
[500_000, 1_500_000)so they never collide with real assignments. Override withGeneFactory.GeneBuilder.withNcbiId(int)if a specific value is needed.
- Author:
- Phase 3 (Vision section 3 - test-fixture rewrite)
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
GeneFactory
public GeneFactory()
-
-
Method Details
-
builder
Start building aGene. All defaults can be overridden viawithXxx(...)methods.
-