@Test public void testSelectOrgByIdWithAllExpand() throws ODataException { UriParameter key = mock(UriParameter.class); when(key.getName()).thenReturn("ID"); when(key.getText()).thenReturn("'2'"); List<UriParameter> keyPredicates = new ArrayList<>(); keyPredicates.add(key); JPAInlineItemInfo item = createOrgExpandRoles(keyPredicates, null); cut = new JPAExpandJoinQuery(OData.newInstance(), sessionContext, item, headers, requestContext, Optional.empty()); JPAExpandQueryResult act = cut.execute(); assertEquals(1, act.getNoResults()); assertEquals(2, act.getNoResultsDeep()); }
@Override public JPAExpandQueryResult execute() throws ODataApplicationException { final int handle = debugger.startRuntimeMeasurement(this, "execute"); long skip = 0; long top = Long.MAX_VALUE; try { tupleQuery = createTupleQuery(); final int resultHandle = debugger.startRuntimeMeasurement(tupleQuery, "getResultList"); final List<Tuple> intermediateResult = tupleQuery.getResultList(); debugger.stopRuntimeMeasurement(resultHandle); if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { if (uriResource.getSkipOption() != null) skip = uriResource.getSkipOption().getValue(); if (uriResource.getTopOption() != null) top = uriResource.getTopOption().getValue(); } final Map<String, List<Tuple>> result = convertResult(intermediateResult, assoziation, skip, top); final Set<JPAPath> requestedSelection = new HashSet<>(); buildSelectionAddNavigationAndSelect(uriResource, requestedSelection, uriResource.getSelectOption()); debugger.stopRuntimeMeasurement(handle); return new JPAExpandQueryResult(result, count(), jpaEntity, requestedSelection); } catch (final JPANoSelectionException e) { return new JPAExpandQueryResult(Collections.emptyMap(), Collections.emptyMap(), this.jpaEntity, Collections .emptyList()); } catch (final ODataJPAModelException e) { throw new ODataApplicationException(e.getLocalizedMessage(), HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), ODataJPAModelException.getLocales().nextElement(), e); } }
JPAExpandJoinQuery extends JPAAbstractJoinQuery { @Override public JPAExpandQueryResult execute() throws ODataApplicationException { final int handle = debugger.startRuntimeMeasurement(this, "execute"); long skip = 0; long top = Long.MAX_VALUE; try { tupleQuery = createTupleQuery(); final int resultHandle = debugger.startRuntimeMeasurement(tupleQuery, "getResultList"); final List<Tuple> intermediateResult = tupleQuery.getResultList(); debugger.stopRuntimeMeasurement(resultHandle); if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { if (uriResource.getSkipOption() != null) skip = uriResource.getSkipOption().getValue(); if (uriResource.getTopOption() != null) top = uriResource.getTopOption().getValue(); } final Map<String, List<Tuple>> result = convertResult(intermediateResult, assoziation, skip, top); final Set<JPAPath> requestedSelection = new HashSet<>(); buildSelectionAddNavigationAndSelect(uriResource, requestedSelection, uriResource.getSelectOption()); debugger.stopRuntimeMeasurement(handle); return new JPAExpandQueryResult(result, count(), jpaEntity, requestedSelection); } catch (final JPANoSelectionException e) { return new JPAExpandQueryResult(Collections.emptyMap(), Collections.emptyMap(), this.jpaEntity, Collections .emptyList()); } catch (final ODataJPAModelException e) { throw new ODataApplicationException(e.getLocalizedMessage(), HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), ODataJPAModelException.getLocales().nextElement(), e); } } }
JPAExpandJoinQuery extends JPAAbstractJoinQuery { @Override public JPAExpandQueryResult execute() throws ODataApplicationException { final int handle = debugger.startRuntimeMeasurement(this, "execute"); long skip = 0; long top = Long.MAX_VALUE; try { tupleQuery = createTupleQuery(); final int resultHandle = debugger.startRuntimeMeasurement(tupleQuery, "getResultList"); final List<Tuple> intermediateResult = tupleQuery.getResultList(); debugger.stopRuntimeMeasurement(resultHandle); if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { if (uriResource.getSkipOption() != null) skip = uriResource.getSkipOption().getValue(); if (uriResource.getTopOption() != null) top = uriResource.getTopOption().getValue(); } final Map<String, List<Tuple>> result = convertResult(intermediateResult, assoziation, skip, top); final Set<JPAPath> requestedSelection = new HashSet<>(); buildSelectionAddNavigationAndSelect(uriResource, requestedSelection, uriResource.getSelectOption()); debugger.stopRuntimeMeasurement(handle); return new JPAExpandQueryResult(result, count(), jpaEntity, requestedSelection); } catch (final JPANoSelectionException e) { return new JPAExpandQueryResult(Collections.emptyMap(), Collections.emptyMap(), this.jpaEntity, Collections .emptyList()); } catch (final ODataJPAModelException e) { throw new ODataApplicationException(e.getLocalizedMessage(), HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), ODataJPAModelException.getLocales().nextElement(), e); } } JPAExpandJoinQuery(final OData odata, final JPAODataCRUDContextAccess sessionContext,
      final JPAInlineItemInfo item, final Map<String, List<String>> requestHeaders,
      final JPAODataRequestContextAccess requestContext, final Optional<JPAKeyBoundary> keyBoundary);  JPAExpandJoinQuery(final OData odata, final JPAODataCRUDContextAccess context,
      final JPAAssociationPath assoziation, final JPAEntityType entityType,
      final Map<String, List<String>> requestHeaders, final JPAODataRequestContextAccess requestContext); }
JPAExpandJoinQuery extends JPAAbstractJoinQuery { @Override public JPAExpandQueryResult execute() throws ODataApplicationException { final int handle = debugger.startRuntimeMeasurement(this, "execute"); long skip = 0; long top = Long.MAX_VALUE; try { tupleQuery = createTupleQuery(); final int resultHandle = debugger.startRuntimeMeasurement(tupleQuery, "getResultList"); final List<Tuple> intermediateResult = tupleQuery.getResultList(); debugger.stopRuntimeMeasurement(resultHandle); if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { if (uriResource.getSkipOption() != null) skip = uriResource.getSkipOption().getValue(); if (uriResource.getTopOption() != null) top = uriResource.getTopOption().getValue(); } final Map<String, List<Tuple>> result = convertResult(intermediateResult, assoziation, skip, top); final Set<JPAPath> requestedSelection = new HashSet<>(); buildSelectionAddNavigationAndSelect(uriResource, requestedSelection, uriResource.getSelectOption()); debugger.stopRuntimeMeasurement(handle); return new JPAExpandQueryResult(result, count(), jpaEntity, requestedSelection); } catch (final JPANoSelectionException e) { return new JPAExpandQueryResult(Collections.emptyMap(), Collections.emptyMap(), this.jpaEntity, Collections .emptyList()); } catch (final ODataJPAModelException e) { throw new ODataApplicationException(e.getLocalizedMessage(), HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), ODataJPAModelException.getLocales().nextElement(), e); } } JPAExpandJoinQuery(final OData odata, final JPAODataCRUDContextAccess sessionContext,
      final JPAInlineItemInfo item, final Map<String, List<String>> requestHeaders,
      final JPAODataRequestContextAccess requestContext, final Optional<JPAKeyBoundary> keyBoundary);  JPAExpandJoinQuery(final OData odata, final JPAODataCRUDContextAccess context,
      final JPAAssociationPath assoziation, final JPAEntityType entityType,
      final Map<String, List<String>> requestHeaders, final JPAODataRequestContextAccess requestContext); @Override JPAExpandQueryResult execute(); }
JPAExpandJoinQuery extends JPAAbstractJoinQuery { @Override public JPAExpandQueryResult execute() throws ODataApplicationException { final int handle = debugger.startRuntimeMeasurement(this, "execute"); long skip = 0; long top = Long.MAX_VALUE; try { tupleQuery = createTupleQuery(); final int resultHandle = debugger.startRuntimeMeasurement(tupleQuery, "getResultList"); final List<Tuple> intermediateResult = tupleQuery.getResultList(); debugger.stopRuntimeMeasurement(resultHandle); if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { if (uriResource.getSkipOption() != null) skip = uriResource.getSkipOption().getValue(); if (uriResource.getTopOption() != null) top = uriResource.getTopOption().getValue(); } final Map<String, List<Tuple>> result = convertResult(intermediateResult, assoziation, skip, top); final Set<JPAPath> requestedSelection = new HashSet<>(); buildSelectionAddNavigationAndSelect(uriResource, requestedSelection, uriResource.getSelectOption()); debugger.stopRuntimeMeasurement(handle); return new JPAExpandQueryResult(result, count(), jpaEntity, requestedSelection); } catch (final JPANoSelectionException e) { return new JPAExpandQueryResult(Collections.emptyMap(), Collections.emptyMap(), this.jpaEntity, Collections .emptyList()); } catch (final ODataJPAModelException e) { throw new ODataApplicationException(e.getLocalizedMessage(), HttpStatusCode.INTERNAL_SERVER_ERROR .getStatusCode(), ODataJPAModelException.getLocales().nextElement(), e); } } JPAExpandJoinQuery(final OData odata, final JPAODataCRUDContextAccess sessionContext,
      final JPAInlineItemInfo item, final Map<String, List<String>> requestHeaders,
      final JPAODataRequestContextAccess requestContext, final Optional<JPAKeyBoundary> keyBoundary);  JPAExpandJoinQuery(final OData odata, final JPAODataCRUDContextAccess context,
      final JPAAssociationPath assoziation, final JPAEntityType entityType,
      final Map<String, List<String>> requestHeaders, final JPAODataRequestContextAccess requestContext); @Override JPAExpandQueryResult execute();  }