Announcement Announcement Module
Collapse
No announcement yet.
Testing with MockRestServiceServer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Testing with MockRestServiceServer

    Trouble testing one of the methods using MockRestServiceServer. Getting null for the value of "customer.getCustomerId()".

    Any suggestions why?

    @Test
    public void test() {
    mockServer.expect(requestTo("..."))
    .andExpect(method(GET))
    .andRespond(withSuccess(str, MediaType.APPLICATION_JSON));
    Customer customer = api.operations().getCustomer();
    assertEquals("foo", customer.getCustomerId());
    assertEquals(new Boolean("TRUE"),customer.isTrue());
    }

    String str = "{ \"customer\": { \"customer-id\": \"foo\",\"is-true\": \"TRUE\" }}";

  • #2
    I couldn't tell you for certain without knowing how the JSON deserialization is working? the field's name is "customer-id", but the property is named "customerId"...is your object mapper configured to convert the dashed field name to a camel-cased property name?

    In short, I believe your problem has less to do with MockRestServiceServer and more to do with how you've implementing the Jackson mapping code. (I'm assuming that you're using Jackson for JSON processing.)

    Comment


    • #3
      Solved.

      Thanks
      Last edited by Laedislaw; Feb 22nd, 2013, 09:57 AM.

      Comment

      Working...
      X