@Override @Test public void testRequestContextUrlFilledForAbsoluteRequestedWithOutSlash() throws SerializerException, ODataJPASerializerException { when(context.useAbsoluteContextURL()).thenReturn(true); when(request.getRawBaseUri()).thenReturn("localhost:8080/v1"); cut.serialize(request, result); verify(serializer).entityCollection(any(), any(), any(), argThat(new EntityCollectionSerializerOptionsMatcher( "localhost:8080/v1/"))); }
@Override public SerializerResult serialize(final ODataRequest request, final EntityCollection result) throws SerializerException, ODataJPASerializerException { final EdmEntitySet targetEdmEntitySet = Util.determineTargetEntitySet(uriInfo.getUriResourceParts()); final String selectList = uriHelper.buildContextURLSelectList(targetEdmEntitySet.getEntityType(), uriInfo.getExpandOption(), uriInfo.getSelectOption()); ContextURL contextUrl; try { contextUrl = ContextURL.with() .serviceRoot(buildServiceRoot(request, serviceContext)) .entitySet(targetEdmEntitySet) .selectList(selectList) .build(); } catch (URISyntaxException e) { throw new ODataJPASerializerException(e, HttpStatusCode.BAD_REQUEST); } final String id = request.getRawBaseUri() + "/" + targetEdmEntitySet.getEntityType().getName(); final EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with() .contextURL(contextUrl) .id(id) .count(uriInfo.getCountOption()) .select(uriInfo.getSelectOption()) .expand(uriInfo.getExpandOption()) .build(); return serializer.entityCollection(this.serviceMetadata, targetEdmEntitySet.getEntityType(), result, opts); }
JPASerializeEntityCollection implements JPAOperationSerializer { @Override public SerializerResult serialize(final ODataRequest request, final EntityCollection result) throws SerializerException, ODataJPASerializerException { final EdmEntitySet targetEdmEntitySet = Util.determineTargetEntitySet(uriInfo.getUriResourceParts()); final String selectList = uriHelper.buildContextURLSelectList(targetEdmEntitySet.getEntityType(), uriInfo.getExpandOption(), uriInfo.getSelectOption()); ContextURL contextUrl; try { contextUrl = ContextURL.with() .serviceRoot(buildServiceRoot(request, serviceContext)) .entitySet(targetEdmEntitySet) .selectList(selectList) .build(); } catch (URISyntaxException e) { throw new ODataJPASerializerException(e, HttpStatusCode.BAD_REQUEST); } final String id = request.getRawBaseUri() + "/" + targetEdmEntitySet.getEntityType().getName(); final EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with() .contextURL(contextUrl) .id(id) .count(uriInfo.getCountOption()) .select(uriInfo.getSelectOption()) .expand(uriInfo.getExpandOption()) .build(); return serializer.entityCollection(this.serviceMetadata, targetEdmEntitySet.getEntityType(), result, opts); } }
JPASerializeEntityCollection implements JPAOperationSerializer { @Override public SerializerResult serialize(final ODataRequest request, final EntityCollection result) throws SerializerException, ODataJPASerializerException { final EdmEntitySet targetEdmEntitySet = Util.determineTargetEntitySet(uriInfo.getUriResourceParts()); final String selectList = uriHelper.buildContextURLSelectList(targetEdmEntitySet.getEntityType(), uriInfo.getExpandOption(), uriInfo.getSelectOption()); ContextURL contextUrl; try { contextUrl = ContextURL.with() .serviceRoot(buildServiceRoot(request, serviceContext)) .entitySet(targetEdmEntitySet) .selectList(selectList) .build(); } catch (URISyntaxException e) { throw new ODataJPASerializerException(e, HttpStatusCode.BAD_REQUEST); } final String id = request.getRawBaseUri() + "/" + targetEdmEntitySet.getEntityType().getName(); final EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with() .contextURL(contextUrl) .id(id) .count(uriInfo.getCountOption()) .select(uriInfo.getSelectOption()) .expand(uriInfo.getExpandOption()) .build(); return serializer.entityCollection(this.serviceMetadata, targetEdmEntitySet.getEntityType(), result, opts); } JPASerializeEntityCollection(final ServiceMetadata serviceMetadata, final ODataSerializer serializer,
      final UriHelper uriHelper, final UriInfo uriInfo, final ContentType responseFormat,
      final JPAODataCRUDContextAccess serviceContext); }
JPASerializeEntityCollection implements JPAOperationSerializer { @Override public SerializerResult serialize(final ODataRequest request, final EntityCollection result) throws SerializerException, ODataJPASerializerException { final EdmEntitySet targetEdmEntitySet = Util.determineTargetEntitySet(uriInfo.getUriResourceParts()); final String selectList = uriHelper.buildContextURLSelectList(targetEdmEntitySet.getEntityType(), uriInfo.getExpandOption(), uriInfo.getSelectOption()); ContextURL contextUrl; try { contextUrl = ContextURL.with() .serviceRoot(buildServiceRoot(request, serviceContext)) .entitySet(targetEdmEntitySet) .selectList(selectList) .build(); } catch (URISyntaxException e) { throw new ODataJPASerializerException(e, HttpStatusCode.BAD_REQUEST); } final String id = request.getRawBaseUri() + "/" + targetEdmEntitySet.getEntityType().getName(); final EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with() .contextURL(contextUrl) .id(id) .count(uriInfo.getCountOption()) .select(uriInfo.getSelectOption()) .expand(uriInfo.getExpandOption()) .build(); return serializer.entityCollection(this.serviceMetadata, targetEdmEntitySet.getEntityType(), result, opts); } JPASerializeEntityCollection(final ServiceMetadata serviceMetadata, final ODataSerializer serializer,
      final UriHelper uriHelper, final UriInfo uriInfo, final ContentType responseFormat,
      final JPAODataCRUDContextAccess serviceContext); @Override SerializerResult serialize(final ODataRequest request, final EntityCollection result); @Override SerializerResult serialize(final Annotatable annotatable, final EdmType entityType, final ODataRequest request); @Override ContentType getContentType(); }
JPASerializeEntityCollection implements JPAOperationSerializer { @Override public SerializerResult serialize(final ODataRequest request, final EntityCollection result) throws SerializerException, ODataJPASerializerException { final EdmEntitySet targetEdmEntitySet = Util.determineTargetEntitySet(uriInfo.getUriResourceParts()); final String selectList = uriHelper.buildContextURLSelectList(targetEdmEntitySet.getEntityType(), uriInfo.getExpandOption(), uriInfo.getSelectOption()); ContextURL contextUrl; try { contextUrl = ContextURL.with() .serviceRoot(buildServiceRoot(request, serviceContext)) .entitySet(targetEdmEntitySet) .selectList(selectList) .build(); } catch (URISyntaxException e) { throw new ODataJPASerializerException(e, HttpStatusCode.BAD_REQUEST); } final String id = request.getRawBaseUri() + "/" + targetEdmEntitySet.getEntityType().getName(); final EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with() .contextURL(contextUrl) .id(id) .count(uriInfo.getCountOption()) .select(uriInfo.getSelectOption()) .expand(uriInfo.getExpandOption()) .build(); return serializer.entityCollection(this.serviceMetadata, targetEdmEntitySet.getEntityType(), result, opts); } JPASerializeEntityCollection(final ServiceMetadata serviceMetadata, final ODataSerializer serializer,
      final UriHelper uriHelper, final UriInfo uriInfo, final ContentType responseFormat,
      final JPAODataCRUDContextAccess serviceContext); @Override SerializerResult serialize(final ODataRequest request, final EntityCollection result); @Override SerializerResult serialize(final Annotatable annotatable, final EdmType entityType, final ODataRequest request); @Override ContentType getContentType();  }