コード例 #1
0
  /** verifies that the return value uses the schema example */
  @Test
  public void verifyGetComplexResponseWithExample() throws Exception {
    Map<String, String> queryParams = new HashMap<String, String>();

    String str =
        client.invokeAPI(
            "/mockResponses/complexResponseWithExample",
            "GET",
            queryParams,
            null,
            new HashMap<String, String>(),
            null,
            "application/json",
            null,
            new String[0]);
    ObjectMapper mapper =
        Json.mapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
    assertEquals(
        mapper.readValue(str, JsonNode.class),
        mapper.readValue("{\n  \"foo\":\"bar\"\n}\n", JsonNode.class));
  }
コード例 #2
0
  /** verifies that the return value generates a schema */
  @Test
  public void verifyGetComplexResponse() throws Exception {
    Map<String, String> queryParams = new HashMap<String, String>();

    String str =
        client.invokeAPI(
            "/mockResponses/complexResponse",
            "GET",
            queryParams,
            null,
            new HashMap<String, String>(),
            null,
            "application/json",
            null,
            new String[0]);
    ObjectMapper mapper =
        Json.mapper().configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
    assertEquals(
        mapper.readValue(str, JsonNode.class),
        mapper.readValue(
            "{\"street\":\"12345 El Monte Road\",\"city\":\"Los Altos Hills\",\"state\":\"CA\",\"zip\":\"94022\"}",
            JsonNode.class));
  }