sahaya / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

mwachala@gmail.com #250

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to deserialize response to an object e.g. post(/path).as(YourClass.class)
2. In my case I receive json object as a response and there were additional 
info in request like : "{"status":"ok","contents":{"Id""

which caused that it could match appropriate path to the fields in class with 
id field because it looks for contents.id not id
3.

What is the expected output? What do you see instead?
I would like to get the object from the response (so the solution is to remove 
the additional information (status, contents) from the request string before 
running deserialization)

What version of the product are you using? On what operating system?
restassured : 1.6.2
on Mac

Please provide any additional information below.

Original issue reported on code.google.com by mwach...@gmail.com on 19 Jul 2013 at 1:35

GoogleCodeExporter commented 9 years ago
which caused that it could NOT match appropriate path to the fields in class 
with id field because it looks for contents.id not id

Original comment by mwach...@gmail.com on 19 Jul 2013 at 1:36

GoogleCodeExporter commented 9 years ago
in the newest version 1.8.1 the follwoing error in logs : 
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized 
field "status" (class com.test.model.Test), not marked as ignorable (4 known 
properties: , "lastName", "email", "company", "Id"])
 at [Source: java.io.StringReader@a4c1b07; line: 1, column: 12] (through reference chain: com.test.model.Test["status"])
    at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79)
    at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:568)
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:650)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:830)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:310)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:112)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2580)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1824)
    at com.fasterxml.jackson.databind.ObjectMapper$readValue.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at com.jayway.restassured.internal.path.json.mapping.JsonPathJackson2ObjectDeserializer.deserialize(JsonPathJackson2ObjectDeserializer.groovy:41)
    at com.jayway.restassured.path.json.mapping.JsonPathObjectDeserializer$deserialize.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at com.jayway.restassured.internal.mapping.Jackson2Mapper.deserialize(Jackson2Mapper.groovy:60)
    at com.jayway.restassured.mapper.ObjectMapper$deserialize.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at com.jayway.restassured.internal.mapping.ObjectMapping.parseWithJackson2(ObjectMapping.groovy:188)
    at com.jayway.restassured.internal.mapping.ObjectMapping$parseWithJackson2.callStatic(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:53)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:157)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:169)
    at com.jayway.restassured.internal.mapping.ObjectMapping.deserialize(ObjectMapping.groovy:51)
    at com.jayway.restassured.internal.mapping.ObjectMapping$deserialize.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at com.jayway.restassured.internal.RestAssuredResponseImpl.as(RestAssuredResponseImpl.groovy:175)

Original comment by mwach...@gmail.com on 19 Jul 2013 at 2:05

GoogleCodeExporter commented 9 years ago
please cancel this issue as it was created by my mistake, Sorry for confusion

Original comment by mwach...@gmail.com on 19 Jul 2013 at 8:05

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 6 Aug 2013 at 7:32

GoogleCodeExporter commented 9 years ago
write what was you mistake at least

Original comment by Spaum.al...@mail.ru on 3 Jun 2014 at 12:50

GoogleCodeExporter commented 9 years ago
The application wrapped the response adding those additional fields 'status', 
'contents' which caused problems when trying to serialize. I added response 
wrapper class which fixed this (I mean it creates the same object and 
serialization was successful) 

Original comment by mwach...@gmail.com on 3 Jun 2014 at 12:56

GoogleCodeExporter commented 9 years ago
I am having the same issue and I am new to rest assured. my response is as 
follows
<response>
 <head>
      <per_page></per_page>
      <page></page>
      <page_count></page_count>
      <link rel="next" href="?per_page=50&page=2"/>
   </head>

<content>
      <orders>
         <order id="12286f05-35b2-40a0-b712-e64be62389d4">
            <status></status>
            <employee></employee>
            <order_date></order_date>
            <store></store>
            <employee>            
            <parent_order_id/>
            <fulfillment_centre_id/>
         </order>
I created 5 fields i.e. id, status, employee, order_date and store(with their 
setters and getters in the class) even though there are more elements but they 
didn't return any value, hence reason for me not to create them as fields. 
mwach, when you said you added response wrapper, can you please explain a bit 
more? thanks

Original comment by oluwandy...@gmail.com on 26 Oct 2014 at 8:48

GoogleCodeExporter commented 9 years ago
Hi,

I my case
I couldn't serialize response to the object because it was wrapped by class
which keep additionally 'status' so I wrote the same on my side so that I
have 'status' field in class to which I want to serialize the response.

I am not sure I understand your issue but it is always good idea to try to
do it step by step so at first I will try statically serialize the response
you get to the object you have, maybe you will get some meaningful
exception.

Original comment by mwach...@gmail.com on 29 Oct 2014 at 9:25