Class DatasetsWebServiceSamplesCursorTest

java.lang.Object
ubic.gemma.rest.DatasetsWebServiceSamplesCursorTest

@ExtendWith(org.mockito.junit.jupiter.MockitoExtension.class) public class DatasetsWebServiceSamplesCursorTest extends Object
Unit tests for the cursor-pagination branch added to DatasetsWebService.getDatasetSamples(DatasetArg, QuantitationTypeArg, boolean, CursorArg, LimitArg, ExcludeArg, boolean) as step 1k of CURSOR_PAGINATION_STEP1_PLAN.md. Pure Mockito — the goal is to verify the WebService routes cursor vs legacy modes to the right helper and emits the right response wrapper, not to retest the DAO (covered by the broader DAO-cursor suite).

Differences from the previous 1e-1j cursor tests: - The legacy mode is NOT offset-paginated for this endpoint — it returns an unpaginated ResponseDataObject<List<BioAssayValueObject>>. The cursor branch is therefore strictly additive (an opt-in via ?cursor=). - The endpoint also accepts quantitationType and useProcessedQuantitationType that select QT-narrowed assay listings; these intentionally remain in the legacy unpaginated mode (their sort and dimension restriction are not expressible as an id-only cursor under the step 1b restriction), so supplying cursor together with either is a 400 Bad Request.

Author:
phase3
  • Constructor Details

    • DatasetsWebServiceSamplesCursorTest

      public DatasetsWebServiceSamplesCursorTest()
  • Method Details

    • setUp

      @BeforeEach public void setUp()
    • legacyModeWithoutCursorReturnsUnpaginatedResponseDataObject

      @Test public void legacyModeWithoutCursorReturnsUnpaginatedResponseDataObject()
    • cursorModeRoutesToCursorHelperAndReturnsCursorPaginatedResponse

      @Test public void cursorModeRoutesToCursorHelperAndReturnsCursorPaginatedResponse()
    • cursorModeDecodesCursorAndForwardsToArgService

      @Test public void cursorModeDecodesCursorAndForwardsToArgService()
    • cursorWithQuantitationTypeIsRejectedAs400

      @Test public void cursorWithQuantitationTypeIsRejectedAs400()
    • limitWithoutCursorIsRejectedAs400

      @Test public void limitWithoutCursorIsRejectedAs400()
      🛑 The route bound limit and then never used it outside cursor mode.

      Measured on production (gemma2, dataset 7332 = GSE2109, 2158 samples): GET /datasets/7332/samples?limit=20 answered with all 2158 assays — the same body as the no-parameter call, 22,846,518 bytes at the time — and nothing in it said the page size had been dropped. Truncating to 20 instead is no better: the legacy response is an unpaginated ResponseDataObject with no totalElements and no nextCursor, so it has nowhere to declare that 2138 rows were left out. A caller must not be able to receive a different number of rows than it asked for without being told, so the parameter is refused.

    • limitWithQuantitationTypeAndNoCursorIsRejectedAs400

      @Test public void limitWithQuantitationTypeAndNoCursorIsRejectedAs400()
      The QT-narrowed listings are legacy-mode too, so they refuse a limit on the same grounds — the rejection is a property of "not paginating", not of the plain branch.
    • cursorModeWithoutLimitUsesTheDefaultPageSize

      @Test public void cursorModeWithoutLimitUsesTheDefaultPageSize()
      Cursor mode still has a page size when the caller sends none — dropping @DefaultValue("20") from the parameter moved that default into the method, and it has to still be there.
    • cursorWithUseProcessedQuantitationTypeIsRejectedAs400

      @Test public void cursorWithUseProcessedQuantitationTypeIsRejectedAs400()