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= or ?limit=; either one selects it, and a bare limit starts at the first page with a null 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 or limit 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()
    • limitWithoutCursorStartsACursorWalkAtTheFirstPage

      @Test public void limitWithoutCursorStartsACursorWalkAtTheFirstPage()
      A limit with no cursor starts a cursor walk at the first page, which is the only way into cursor mode from a standing start: this listing has no offset mode, so nothing it can return without a cursor carries a nextCursor to continue from.

      It also makes a short answer possible at all. Measured on production (gemma2, dataset 7332 = GSE2109, 2158 samples), GET /datasets/7332/samples?limit=20 used to answer with all 2158 assays — the same body as the no-parameter call, 22,846,518 bytes at the time — with nothing in it saying the page size had been dropped. Truncating the unpaginated ResponseDataObject to 20 would have been no better, since it has no totalElements and no nextCursor in which to declare that 2138 rows were left out; the cursor wrapper does.

    • limitWithQuantitationTypeAndNoCursorIsRejectedAs400

      @Test public void limitWithQuantitationTypeAndNoCursorIsRejectedAs400()
      The QT-narrowed listings stay unpaginated — they sort by assay name and restrict to a BioAssayDimension, neither of which an id-only cursor can express — so a limit there is refused rather than dropped, on the same grounds as a cursor.
    • 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()