Class DatasetsDiagnosticsRestTest

java.lang.Object
org.glassfish.jersey.test.JerseyTest
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@Tag("integration") public class DatasetsDiagnosticsRestTest extends BaseJerseyIntegrationTest5
Integration tests for the diagnostics endpoints (mean-variance, sample-correlation, svd) on DatasetsWebService. Each test exercises the real Hibernate session lifecycle that the mock-based DatasetsWebServiceTest cannot reproduce.

Regression target #1: the mean-variance handler previously called ee.getMeanVarianceRelation().getMeans() on the entity returned by DatasetArgService.getEntity(), which carries a lazy MVR proxy. Outside the service-bounded Hibernate session this threw LazyInitializationException (HTTP 500). The fix in commit a70e3dc8f6 switched to expressionExperimentService.loadWithMeanVarianceRelation. Builds before that commit fail testGetDatasetMeanVarianceReturnsArrays() with a 500.

Regression target #2: the SVDResult constructor previously assigned pca.getExperimentAnalyzed() (returns a BioAssaySet-typed Hibernate proxy) directly to its ExpressionExperiment field. The implicit checkcast inserted by javac threw ClassCastException, caught + logged message-only by SVDServiceImpl.getSvd, which returned null silently. The fix in dd63676978 calls Hibernate.unproxy(Object) in the constructor and switched the catch-block to log the full stack. getDatasetSvd_returns200_andExperimentAnalyzedSurfacesUnderlyingEntity() locks this in: pre-fix, the call returned 404 instead of 200.

  • Constructor Details

    • DatasetsDiagnosticsRestTest

      public DatasetsDiagnosticsRestTest()
  • Method Details

    • setUpFixtures

      @BeforeEach public void setUpFixtures()
    • tearDownFixtures

      @AfterEach public void tearDownFixtures()
    • testGetDatasetMeanVarianceReturnsArrays

      @Test public void testGetDatasetMeanVarianceReturnsArrays()
      Regression guard: calling the handler must not throw LazyInitializationException. Pre-a70e3dc8f6 this returned HTTP 500.
    • testGetDatasetMeanVarianceHttp200

      @Test public void testGetDatasetMeanVarianceHttp200()
      Wire-shape check: the HTTP response is 200 with a JSON body containing the means array. Complements the direct-handler call above by exercising the Jersey serialization path.
    • testGetDatasetMeanVarianceWhenNoneIs404

      @Test public void testGetDatasetMeanVarianceWhenNoneIs404()
      Negative case: a dataset without an MVR returns 404 (NotFoundException from the handler).
    • testGetDatasetMeanVarianceWithUnknownDatasetIs404

      @Test public void testGetDatasetMeanVarianceWithUnknownDatasetIs404()
    • getDatasetSvd_returns200_andExperimentAnalyzedSurfacesUnderlyingEntity

      @Test public void getDatasetSvd_returns200_andExperimentAnalyzedSurfacesUnderlyingEntity()
      Regression guard for dd63676978. Pre-fix, the SVDResult constructor's implicit checkcast on pca.getExperimentAnalyzed() threw ClassCastException (because the generic-erased Hibernate proxy is typed BioAssaySet, not ExpressionExperiment). SVDServiceImpl.getSvd caught it message-only and returned null, surfacing the call as a 404 on /svd. Post-fix:
      • Hibernate.unproxy(...) lets the underlying EE surface,
      • the catch logs the full stack (any future CCE-style regression is visible).
      The assertion bar here is "no throw, HTTP 200, arrays non-empty" — that proves the constructor succeeded against a real proxied EE.
    • getDatasetSvdLoadings_returns200_forValidPcAndTop

      @Test public void getDatasetSvdLoadings_returns200_forValidPcAndTop()
      Companion: /svd/loadings on a valid PCA should return 200 with at most top rows and the requested PC. Pre-fix, this surfaced as 500 because getSvd() returned null after the SVDResult-ctor CCE while hasSvd() was still true.
    • getDatasetSvd_returns404_whenNoSvd

      @Test public void getDatasetSvd_returns404_whenNoSvd()
      Negative case: an EE without a PCA → 404. Locks in the "throw new NotFoundException" branch in getDatasetSvd.
    • getDatasetSvdLoadings_returns404_whenNoSvd

      @Test public void getDatasetSvdLoadings_returns404_whenNoSvd()
      Negative case: /svd/loadings on an EE without a PCA → 404. The hasSvd() short-circuit covers this; we also exercise the wire path.
    • testGetDatasetSampleCorrelationWhenNoneIs404

      @Test public void testGetDatasetSampleCorrelationWhenNoneIs404()
      GET /sample-correlation returns 404 when the dataset has no SampleCoexpressionAnalysis. Cheap fixture (no SCA computed).
    • testMarkSampleOutlierViaPutEndpointFlipsIsOutlier

      @Test public void testMarkSampleOutlierViaPutEndpointFlipsIsOutlier()
      PUT /samples/{bioAssayId}/outlier flips isOutlier=true on the targeted BioAssay. Re-load through the BioAssayService to confirm the persisted state.
    • testBatchMarkOutliersMarksAndUnmarksAtomically

      @Test public void testBatchMarkOutliersMarksAndUnmarksAtomically()
      POST /samples/outliers atomically marks one assay and unmarks another. The response carries the post-state full outlier set; the marked id is present, the unmarked id is absent.
    • testBatchMarkOutliersReturns400WhenIdDoesntBelongToDataset

      @Test public void testBatchMarkOutliersReturns400WhenIdDoesntBelongToDataset()
      POST /samples/outliers must reject ids that don't belong to the path-derived dataset with HTTP 400, AND must not mutate any state. Validation runs before any service call so the EE's outlier set is unchanged after the call.
    • testBatchMarkOutliersReturns400WhenIdInBothMarkAndUnmark

      @Test public void testBatchMarkOutliersReturns400WhenIdInBothMarkAndUnmark()
      POST /samples/outliers rejects an id that appears in BOTH mark and unmark (ambiguous caller-side delta) with HTTP 400.
    • testGetDatasetQcMetricsWhenThereIsNothingIs404

      @Test public void testGetDatasetQcMetricsWhenThereIsNothingIs404()
      A dataset with no MultiQC report and no sequencing read counts has nothing to show, so the endpoint 404s rather than returning an empty row per assay.
    • testGetDatasetQcMetricsServesTheDatabaseReadCountWithoutAReport

      @Test public void testGetDatasetQcMetricsServesTheDatabaseReadCountWithoutAReport()
      Most RNA-seq assays carry a read count in the database while only a minority of datasets have a MultiQC report, so a read count alone has to answer 200 — with reportPresent false so the caller can tell the two apart.