You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Riccardo Mariani <ma...@gmail.com> on 2015/09/25 08:28:37 UTC

ExpressionVisitor test case

Hi Olingo users,
I'm using the Olingo library v4.0.0.

I'd like to unit test the visitMember(UriInfoResource) method of my 
implementation of the ExpressionVisitor.
For example I'd like to test the visitMember(UriInfoResource) method 
using an UriInfoImpl object containing a single UriResourceFunctionImpl.

Is there a way to create a such UriInfoImpl object from an uri in a fast 
way?
I mean using some Olingo object which parse the uri and returns an 
UriInfoImpl.
I don't want to reinvent the wheel because I know Olingo already builds 
this object from the uri.

Thank you a lot,

Riccardo.

Re: ExpressionVisitor test case

Posted by Riccardo Mariani <ma...@gmail.com>.
Hi Christian,
it's exactly what I need.

Thank you, your answers are always very useful.

On 25/09/15 15:31, Christian Amend wrote:
> Hi Riccardo,
>
> unfortunately we do not provide access to the URI parser via our
> Olingo API. This means for your Unit Tests you would need a compile
> dependency to our server-core.
>
> With the core dependency which I only recommend for unit testing you
> can do something like this:
>
>    UriInfo  uriInfo = new Parser().parseUri(request.getRawODataPath(),
> request.getRawQueryPath(), null, serviceMetadata.getEdm());
>
> To reproduce the way we calculate the ODataPath from a servlet request
> have a look at our fillUriInformation method which can only be found
> in the ODataHttpHandlerImpl class inside the core library.
>
> I hope this helps your use case for unit testing. I would not
> recommend to have a compile dependency to the server core for your
> productive code as we might change/rename stuff in the core without
> notice.
>
> Best Regards,
> Christian
>
> On Fri, Sep 25, 2015 at 8:28 AM, Riccardo Mariani
> <ma...@gmail.com> wrote:
>> Hi Olingo users,
>> I'm using the Olingo library v4.0.0.
>>
>> I'd like to unit test the visitMember(UriInfoResource) method of my
>> implementation of the ExpressionVisitor.
>> For example I'd like to test the visitMember(UriInfoResource) method using
>> an UriInfoImpl object containing a single UriResourceFunctionImpl.
>>
>> Is there a way to create a such UriInfoImpl object from an uri in a fast
>> way?
>> I mean using some Olingo object which parse the uri and returns an
>> UriInfoImpl.
>> I don't want to reinvent the wheel because I know Olingo already builds this
>> object from the uri.
>>
>> Thank you a lot,
>>
>> Riccardo.


Re: ExpressionVisitor test case

Posted by Christian Amend <ch...@apache.org>.
Hi Riccardo,

unfortunately we do not provide access to the URI parser via our
Olingo API. This means for your Unit Tests you would need a compile
dependency to our server-core.

With the core dependency which I only recommend for unit testing you
can do something like this:

  UriInfo  uriInfo = new Parser().parseUri(request.getRawODataPath(),
request.getRawQueryPath(), null, serviceMetadata.getEdm());

To reproduce the way we calculate the ODataPath from a servlet request
have a look at our fillUriInformation method which can only be found
in the ODataHttpHandlerImpl class inside the core library.

I hope this helps your use case for unit testing. I would not
recommend to have a compile dependency to the server core for your
productive code as we might change/rename stuff in the core without
notice.

Best Regards,
Christian

On Fri, Sep 25, 2015 at 8:28 AM, Riccardo Mariani
<ma...@gmail.com> wrote:
> Hi Olingo users,
> I'm using the Olingo library v4.0.0.
>
> I'd like to unit test the visitMember(UriInfoResource) method of my
> implementation of the ExpressionVisitor.
> For example I'd like to test the visitMember(UriInfoResource) method using
> an UriInfoImpl object containing a single UriResourceFunctionImpl.
>
> Is there a way to create a such UriInfoImpl object from an uri in a fast
> way?
> I mean using some Olingo object which parse the uri and returns an
> UriInfoImpl.
> I don't want to reinvent the wheel because I know Olingo already builds this
> object from the uri.
>
> Thank you a lot,
>
> Riccardo.