@Test public void testReturnNullIfEntitySetIsUnknown() throws ODataApplicationException { final UriInfo info = buildUriInfo(); final JPAExamplePagingProvider cut = createPersonCut(5); final JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); assertNull(act); }
@Override public JPAODataPage getFirstPage(final UriInfo uriInfo, final Integer preferedPageSize, final JPACountQuery countQuery, final EntityManager em) throws ODataApplicationException { final UriResource root = uriInfo.getUriResourceParts().get(0); if (root instanceof UriResourceEntitySet) { final Integer maxSize = maxPageSizes.get(((UriResourceEntitySet) root).getEntitySet().getName()); if (maxSize != null) { final Integer skipValue = uriInfo.getSkipOption() != null ? uriInfo.getSkipOption().getValue() : 0; final Integer topValue = uriInfo.getTopOption() != null ? uriInfo.getTopOption().getValue() : null; final Long count = topValue != null ? (topValue + skipValue) : countQuery.countResults(); final Integer size = preferedPageSize != null && preferedPageSize < maxSize ? preferedPageSize : maxSize; String skiptoken = null; if (size < count) skiptoken = UUID.randomUUID().toString(); final JPAODataPage page = new JPAODataPage(uriInfo, skipValue, topValue != null && topValue < size ? topValue : size, skiptoken); if (skiptoken != null) addToChach(page, count); return page; } } return null; }
JPAExamplePagingProvider implements JPAODataPagingProvider { @Override public JPAODataPage getFirstPage(final UriInfo uriInfo, final Integer preferedPageSize, final JPACountQuery countQuery, final EntityManager em) throws ODataApplicationException { final UriResource root = uriInfo.getUriResourceParts().get(0); if (root instanceof UriResourceEntitySet) { final Integer maxSize = maxPageSizes.get(((UriResourceEntitySet) root).getEntitySet().getName()); if (maxSize != null) { final Integer skipValue = uriInfo.getSkipOption() != null ? uriInfo.getSkipOption().getValue() : 0; final Integer topValue = uriInfo.getTopOption() != null ? uriInfo.getTopOption().getValue() : null; final Long count = topValue != null ? (topValue + skipValue) : countQuery.countResults(); final Integer size = preferedPageSize != null && preferedPageSize < maxSize ? preferedPageSize : maxSize; String skiptoken = null; if (size < count) skiptoken = UUID.randomUUID().toString(); final JPAODataPage page = new JPAODataPage(uriInfo, skipValue, topValue != null && topValue < size ? topValue : size, skiptoken); if (skiptoken != null) addToChach(page, count); return page; } } return null; } }
JPAExamplePagingProvider implements JPAODataPagingProvider { @Override public JPAODataPage getFirstPage(final UriInfo uriInfo, final Integer preferedPageSize, final JPACountQuery countQuery, final EntityManager em) throws ODataApplicationException { final UriResource root = uriInfo.getUriResourceParts().get(0); if (root instanceof UriResourceEntitySet) { final Integer maxSize = maxPageSizes.get(((UriResourceEntitySet) root).getEntitySet().getName()); if (maxSize != null) { final Integer skipValue = uriInfo.getSkipOption() != null ? uriInfo.getSkipOption().getValue() : 0; final Integer topValue = uriInfo.getTopOption() != null ? uriInfo.getTopOption().getValue() : null; final Long count = topValue != null ? (topValue + skipValue) : countQuery.countResults(); final Integer size = preferedPageSize != null && preferedPageSize < maxSize ? preferedPageSize : maxSize; String skiptoken = null; if (size < count) skiptoken = UUID.randomUUID().toString(); final JPAODataPage page = new JPAODataPage(uriInfo, skipValue, topValue != null && topValue < size ? topValue : size, skiptoken); if (skiptoken != null) addToChach(page, count); return page; } } return null; } JPAExamplePagingProvider(Map<String, Integer> pageSizes);  JPAExamplePagingProvider(Map<String, Integer> pageSizes, final int bufferSize); }
JPAExamplePagingProvider implements JPAODataPagingProvider { @Override public JPAODataPage getFirstPage(final UriInfo uriInfo, final Integer preferedPageSize, final JPACountQuery countQuery, final EntityManager em) throws ODataApplicationException { final UriResource root = uriInfo.getUriResourceParts().get(0); if (root instanceof UriResourceEntitySet) { final Integer maxSize = maxPageSizes.get(((UriResourceEntitySet) root).getEntitySet().getName()); if (maxSize != null) { final Integer skipValue = uriInfo.getSkipOption() != null ? uriInfo.getSkipOption().getValue() : 0; final Integer topValue = uriInfo.getTopOption() != null ? uriInfo.getTopOption().getValue() : null; final Long count = topValue != null ? (topValue + skipValue) : countQuery.countResults(); final Integer size = preferedPageSize != null && preferedPageSize < maxSize ? preferedPageSize : maxSize; String skiptoken = null; if (size < count) skiptoken = UUID.randomUUID().toString(); final JPAODataPage page = new JPAODataPage(uriInfo, skipValue, topValue != null && topValue < size ? topValue : size, skiptoken); if (skiptoken != null) addToChach(page, count); return page; } } return null; } JPAExamplePagingProvider(Map<String, Integer> pageSizes);  JPAExamplePagingProvider(Map<String, Integer> pageSizes, final int bufferSize); @Override JPAODataPage getNextPage(final String skiptoken); @Override JPAODataPage getFirstPage(final UriInfo uriInfo, final Integer preferedPageSize,
      final JPACountQuery countQuery, final EntityManager em); }
JPAExamplePagingProvider implements JPAODataPagingProvider { @Override public JPAODataPage getFirstPage(final UriInfo uriInfo, final Integer preferedPageSize, final JPACountQuery countQuery, final EntityManager em) throws ODataApplicationException { final UriResource root = uriInfo.getUriResourceParts().get(0); if (root instanceof UriResourceEntitySet) { final Integer maxSize = maxPageSizes.get(((UriResourceEntitySet) root).getEntitySet().getName()); if (maxSize != null) { final Integer skipValue = uriInfo.getSkipOption() != null ? uriInfo.getSkipOption().getValue() : 0; final Integer topValue = uriInfo.getTopOption() != null ? uriInfo.getTopOption().getValue() : null; final Long count = topValue != null ? (topValue + skipValue) : countQuery.countResults(); final Integer size = preferedPageSize != null && preferedPageSize < maxSize ? preferedPageSize : maxSize; String skiptoken = null; if (size < count) skiptoken = UUID.randomUUID().toString(); final JPAODataPage page = new JPAODataPage(uriInfo, skipValue, topValue != null && topValue < size ? topValue : size, skiptoken); if (skiptoken != null) addToChach(page, count); return page; } } return null; } JPAExamplePagingProvider(Map<String, Integer> pageSizes);  JPAExamplePagingProvider(Map<String, Integer> pageSizes, final int bufferSize); @Override JPAODataPage getNextPage(final String skiptoken); @Override JPAODataPage getFirstPage(final UriInfo uriInfo, final Integer preferedPageSize,
      final JPACountQuery countQuery, final EntityManager em);  }