public static Object jsonToObject(String content) throws IOException { return content.trim().startsWith("[") ? jsonToList(content) : jsonToMap(content); }
private Object toJsonObject() throws IOException { if (!(toBeVerified instanceof String)) { return toBeVerified; } String verifying = (String) toBeVerified; assertNotEmpty(verifying); return jsonToObject(verifying); } }
public static Object toJSONAware(Object content) throws JsonProcessingException { if (content instanceof List) { return new JSONArray(toJsonString(content)); } else if (content instanceof Map) { return new JSONObject(toJsonString(content)); } else { return content; } }
@Then("^verify: '([^\"]*)' has size: (\\d+)$") public void hasSize(String path, Integer size) throws IOException { assertThat(size(actual.json(path)), is(size)); }
private void validateJsonSchema(Object actual, String schemaJson) throws IOException { SchemaLoader loader = SchemaLoader.builder().schemaJson(new JSONObject(schemaJson)).build(); Schema schema = loader.load().build(); schema.validate(toJSONAware(actual)); } }
@Then("^verify: '([^\"]*)' has size: (\\d+)$") public void hasSize(String path, Integer size) throws IOException { assertThat(size(actual.json(path)), is(size)); }
private void validateJsonSchema(Object actual, String schemaJson) throws IOException { SchemaLoader loader = SchemaLoader.builder().schemaJson(new JSONObject(schemaJson)).build(); Schema schema = loader.load().build(); schema.validate(toJSONAware(actual)); } }
public static Object jsonToObject(String content) throws IOException { return content.trim().startsWith("[") ? jsonToList(content) : jsonToMap(content); }
public static Object toJSONAware(Object content) throws JsonProcessingException { if (content instanceof List) { return new JSONArray(toJsonString(content)); } else if (content instanceof Map) { return new JSONObject(toJsonString(content)); } else { return content; } }
@Then("^verify: \\$\\{([^\"]*)} has size: (\\d+)$") public void variableHasSize(String name, Integer size) { assertThat(size(variables.get(name)), is(size)); }
private Object toJsonObject() throws IOException { if (!(toBeVerified instanceof String)) { return toBeVerified; } String verifying = (String) toBeVerified; assertNotEmpty(verifying); return jsonToObject(verifying); } }
private String json(String jsonPath) { try { return toJsonString(verifying.json(jsonPath)); } catch (IOException e) { throw new RuntimeException(e); } } }
@Then("^verify: \\$\\{([^\"]*)} has size: (\\d+)$") public void variableHasSize(String name, Integer size) { assertThat(size(variables.get(name)), is(size)); }
private String json(String jsonPath) { try { return toJsonString(verifying.json(jsonPath)); } catch (IOException e) { throw new RuntimeException(e); } } }