Results 1 to 3 of 3

Thread: Testing with MockRestServiceServer

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    1,075

    Default

    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.)
    Craig Walls
    Spring Social Project Lead

  3. #3

    Default

    Solved.

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •