Class TaxonFactory
java.lang.Object
ubic.gemma.core.util.test.fixture.TaxonFactory
Typed factory for persistent
Taxon test fixtures.
This is the Phase 3 replacement for
PersistentDummyObjectHelper.getTestPersistentTaxon() and the
private getTestNonPersistentTaxon() helper. It exists primarily
to make HB6-safe "resolve existing seed, don't fabricate transient"
the easy default — the old pattern of Taxon.Factory.newInstance()
+ setCommonName("mouse") and hoping the persister deduplicates
worked under HB5 but broke under HB6.
Usage:
Taxon mouse = taxonFactory.mouse(); // seeded taxon (NCBI 10090)
Taxon human = taxonFactory.human(); // seeded taxon (NCBI 9606)
Taxon rat = taxonFactory.byCommonName("rat").build();
Taxon adhoc = taxonFactory.adHoc().build(); // freshly-created (admin-only)
Taxon adhoc = taxonFactory.adHoc()
.withNcbiId(99999)
.withScientificName("Testus testus")
.withCommonName("testbeast")
.build();
Design notes:
- The seeded-taxon shortcuts (
mouse(),human(),rat(),zebrafish(),fly(),worm(),yeast()) resolve straight to the seeded row frominit-data.sql. They throw if the seed isn't there. byCommonName(String)/byNcbiId(Integer)/byScientificName(String)are the same idea, parameterized.adHoc()is the only path that ever creates a newTaxonrow. It is intended for tests that need to verify behaviour on a taxon distinct from the seeded set (e.g. yeast-second-NCBI cases, taxon admin tests). Generates a randomized NCBI id (50000+ to stay clear of any real assignment) and a random scientific + common name. The factory persists throughTaxonService#findOrCreate(Taxon)so the path mirrors the production admin flow.- Default
isGenesUsable=truefor ad-hoc taxa — this is what almost every test wants. UseTaxonFactory.AdHocBuilder.withGenesUsable(boolean)to override.
- Author:
- Phase 3 (Vision section 3 - test-fixture rewrite)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for a newly-created ad-hoc taxon.static final classBuilder for a resolved (seeded) taxon. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadHoc()Start building a freshly-created (non-seeded) taxon.byCommonName(String commonName) Resolve a seeded taxon by its common name.Resolve a seeded taxon by its NCBI id.byScientificName(String scientificName) Resolve a seeded taxon by its scientific name.fly()Resolve the seeded fly taxon (NCBI 7227).human()Resolve the seeded human taxon (NCBI 9606).mouse()Resolve the seeded mouse taxon (NCBI 10090).rat()Resolve the seeded rat taxon (NCBI 10116).worm()Resolve the seeded worm taxon (NCBI 6239).yeast()Resolve the seeded yeast taxon (NCBI 4932, secondary 559292).Resolve the seeded zebrafish taxon (NCBI 7955).
-
Constructor Details
-
TaxonFactory
public TaxonFactory()
-
-
Method Details
-
mouse
Resolve the seeded mouse taxon (NCBI 10090). -
human
Resolve the seeded human taxon (NCBI 9606). -
rat
Resolve the seeded rat taxon (NCBI 10116). -
zebrafish
Resolve the seeded zebrafish taxon (NCBI 7955). -
fly
Resolve the seeded fly taxon (NCBI 7227). -
worm
Resolve the seeded worm taxon (NCBI 6239). -
yeast
Resolve the seeded yeast taxon (NCBI 4932, secondary 559292). -
byCommonName
Resolve a seeded taxon by its common name. Throws if not present. -
byScientificName
Resolve a seeded taxon by its scientific name. Throws if not present. -
byNcbiId
Resolve a seeded taxon by its NCBI id. Throws if not present. -
adHoc
Start building a freshly-created (non-seeded) taxon. Defaults to a randomized scientific name, common name, and NCBI id;isGenesUsable=true. Caller is responsible for cleaning up unless the test extends a context that does it for them.
-