use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project textdb by TextDB.
the class PlanStoreResourceTest method checkJsonEquivalence.
public static boolean checkJsonEquivalence(String json1, String json2) throws IOException {
ObjectMapper mapper = new ObjectMapper();
JsonNode tree1 = mapper.readTree(json1);
JsonNode tree2 = mapper.readTree(json2);
return tree1.equals(tree2);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project textdb by TextDB.
the class JsonSerializationTest method testIntegerField.
@Test
public void testIntegerField() {
IntegerField integerField = new IntegerField(100);
JsonNode jsonNode = TestUtils.testJsonSerialization(integerField);
Assert.assertTrue(jsonNode.get(JsonConstants.FIELD_VALUE).isInt());
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project textdb by TextDB.
the class PredicateBaseTest method testPredicate.
/*
* A helper test function to assert if a predicate is
* serialized / deserialized correctly
* by converting predicate to json, then back to predicate, then back to json again,
* assert two json strings are the same, (test if anything changed between conversions)
* and the json contains "operatorType" and "id". (test if the predicate is registered in PredicateBase)
*
*/
public static void testPredicate(PredicateBase predicate) throws Exception {
JsonNode jsonNode = TestUtils.testJsonSerialization(predicate);
Assert.assertTrue(jsonNode.has(PropertyNameConstants.OPERATOR_TYPE));
Assert.assertTrue(jsonNode.has(PropertyNameConstants.OPERATOR_ID));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project KaiZen-OpenAPI-Editor by RepreZen.
the class SwaggerSchema method allowJsonRefInContext.
public void allowJsonRefInContext(String jsonReferenceContext, boolean allow) {
if (jsonRefContexts.get(jsonReferenceContext) == null) {
throw new IllegalArgumentException("Invalid JSON Reference Context: " + jsonReferenceContext);
}
// special case
if (SwaggerPreferenceConstants.VALIDATION_REF_SECURITY_DEFINITIONS_OBJECT.equals(jsonReferenceContext)) {
allowJsonRefInSecurityDefinitionsObject(allow);
return;
}
ArrayNode definition = (ArrayNode) jsonRefContexts.get(jsonReferenceContext);
// should preserve order of the original ArrayNode._children
List<JsonNode> children = Lists.newArrayList(definition.elements());
int indexOfJsonReference = children.indexOf(refToJsonReferenceNode);
boolean alreadyHasJsonReference = indexOfJsonReference > -1;
if (allow) {
if (!alreadyHasJsonReference) {
definition.add(refToJsonReferenceNode.deepCopy());
}
} else {
// disallow
if (alreadyHasJsonReference) {
definition.remove(indexOfJsonReference);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project KaiZen-OpenAPI-Editor by RepreZen.
the class MultipleSwaggerErrorBuilder method getHumanFriendlyText.
protected String getHumanFriendlyText(JsonNode swaggerSchemaNode, final String defaultValue) {
JsonNode title = swaggerSchemaNode.get("title");
if (title != null) {
return title.asText();
}
// nested array
if (swaggerSchemaNode.get("items") != null) {
return getHumanFriendlyText(swaggerSchemaNode.get("items"), defaultValue);
}
// "$ref":"#/definitions/headerParameterSubSchema"
JsonNode ref = swaggerSchemaNode.get("$ref");
if (ref != null) {
return getLabelForRef(ref.asText());
}
// Auxiliary oneOf in "oneOf": [ { "$ref": "#/definitions/securityRequirement" }]
JsonNode oneOf = swaggerSchemaNode.get("oneOf");
if (oneOf != null) {
if (oneOf instanceof ArrayNode) {
ArrayNode arrayNode = (ArrayNode) oneOf;
if (arrayNode.size() > 0) {
Iterator<String> labels = transform(arrayNode.elements(), new Function<JsonNode, String>() {
@Override
public String apply(JsonNode el) {
return getHumanFriendlyText(el, defaultValue);
}
});
return "[" + Joiner.on(", ").join(labels) + "]";
}
}
}
return defaultValue;
}
Aggregations