Class ArrayDesignFactory

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

@Component public class ArrayDesignFactory extends Object
Typed factory for persistent ArrayDesign test fixtures.

This is the Phase 3 replacement for PersistentDummyObjectHelper.getTestPersistentArrayDesign(...). It produces a persistent ArrayDesign with optional probes (CompositeSequence) and optional sequences (BioSequence).

Usage:

  // Empty AD, default mouse taxon, ONECOLOR
  ArrayDesign ad = arrayDesignFactory.oneColor().build();

  // AD with 10 probes, no biosequences
  ArrayDesign ad = arrayDesignFactory.oneColor().withProbes(10).build();

  // AD with 10 probes, each with a BioSequence attached (GenBank entry)
  ArrayDesign ad = arrayDesignFactory.oneColor()
                      .withProbes(10)
                      .withSequences(true)
                      .withTaxon(humanTaxon)
                      .build();

  // Two-color (cdna probe) variant
  ArrayDesign ad = arrayDesignFactory.twoColor().withProbes(20).build();

  // Affymetrix-style "GENE_CHIP" with deterministic probe naming
  ArrayDesign ad = arrayDesignFactory.geneChip()
                      .withProbes(50)
                      .withRandomProbeNames(false)
                      .build();

Design notes (HB6-relevant):

  • build() persists the AD via SecurableBaseImmutableService.create(ArrayDesign) so the ACL-creation listener fires through the production code path (mirrors how real ADs are created on ingest).
  • CompositeSequences are attached to ad.getCompositeSequences() via add(...) (not via setCompositeSequences(new HashSet<>(...))). The CS→AD set has cascade=all on the AD side, so CSes persist as a side effect of AD persist.
  • BioSequences are persisted FIRST via BioSequenceService.findOrCreate(Collection) because the CS→biologicalCharacteristic FK has no cascade. Skipping this caused HB5→HB6 breakage; doing it explicitly is the safe pattern.
  • Taxa are resolved via TaxonFactory so they come from the seeded init-data.sql rows (never fabricated transient).
  • GenBank ExternalDatabase is resolved from ExternalDatabaseService.findByName(String); only the DatabaseEntry that links to it is transient.
Author:
Phase 3 (Vision section 3 - test-fixture rewrite)
  • Constructor Details

    • ArrayDesignFactory

      public ArrayDesignFactory()
  • Method Details

    • oneColor

      public ArrayDesignFactory.Builder oneColor()
      Start building a one-color (single-channel) array design. Default flavour for most expression tests.
    • twoColor

      public ArrayDesignFactory.Builder twoColor()
      Start building a two-color (dual-channel, cDNA) array design.
    • geneChip

      public ArrayDesignFactory.Builder geneChip()
      Start building a "GENE_CHIP" (Affymetrix-style) array design.
    • withTechnologyType

      public ArrayDesignFactory.Builder withTechnologyType(TechnologyType tt)
      Start building an array design with a caller-supplied technology type. Prefer the named starters above when they fit.