Search in sources :

Example 51 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project jsonschema2pojo by joelittlejohn.

the class FragmentResolverTest method attemptToUsePropertyNameOnArrayNodeThrowsIllegalArgumentException.

@Test(expected = IllegalArgumentException.class)
public void attemptToUsePropertyNameOnArrayNodeThrowsIllegalArgumentException() {
    ObjectNode root = new ObjectMapper().createObjectNode();
    ArrayNode a = root.arrayNode();
    root.set("a", a);
    resolver.resolve(root, "#/a/b", "#/.");
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 52 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project jsonschema2pojo by joelittlejohn.

the class FragmentResolverTest method missingPathThrowsIllegalArgumentException.

@Test(expected = IllegalArgumentException.class)
public void missingPathThrowsIllegalArgumentException() {
    ObjectNode root = new ObjectMapper().createObjectNode();
    resolver.resolve(root, "#/a/b/c", "#/.");
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 53 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project OpenAM by OpenRock.

the class SubjectTypesResource method jsonify.

/**
     * Transforms a subclass of {@link EntitlementSubject} in to a JsonSchema representation.
     * This schema is then combined with the Subject's name (taken as the resourceId) and all this is
     * compiled together into a new {@link JsonValue} object until "title" and "config" fields respectively.
     *
     * @param subjectClass The class whose schema to produce.
     * @param resourceId The ID of the resource to return
     * @return A JsonValue containing the schema of the EntitlementSubject
     */
private JsonValue jsonify(Class<? extends EntitlementSubject> subjectClass, String resourceId, boolean logical) {
    try {
        final JsonSchema schema = mapper.generateJsonSchema(subjectClass);
        //this will remove the 'subjectName' attribute from those subjects which incorporate it unnecessarily
        final JsonNode node = schema.getSchemaNode().get("properties");
        if (node instanceof ObjectNode) {
            final ObjectNode alter = (ObjectNode) node;
            alter.remove("subjectName");
        }
        return JsonValue.json(JsonValue.object(JsonValue.field(JSON_OBJ_TITLE, resourceId), JsonValue.field(JSON_OBJ_LOGICAL, logical), JsonValue.field(JSON_OBJ_CONFIG, schema)));
    } catch (JsonMappingException e) {
        if (debug.errorEnabled()) {
            debug.error("SubjectTypesResource :: JSONIFY - Error applying " + "jsonification to the Subject class representation.", e);
        }
        return null;
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonSchema(com.fasterxml.jackson.databind.jsonschema.JsonSchema) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 54 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project KaiZen-OpenAPI-Editor by RepreZen.

the class SwaggerSchema method allowJsonRefInSecurityDefinitionsObject.

protected void allowJsonRefInSecurityDefinitionsObject(boolean allow) {
    ObjectNode definition = (ObjectNode) jsonRefContexts.get(SwaggerPreferenceConstants.VALIDATION_REF_SECURITY_DEFINITIONS_OBJECT);
    if (allow) {
        ObjectNode propertiesNode = definition.putObject("properties");
        propertiesNode.putObject("$ref").put("type", "string");
    } else {
        definition.remove("properties");
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode)

Example 55 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project azure-sdk-for-java by Azure.

the class DeployUsingARMTemplateWithTags method validateAndAddFieldValue.

private static void validateAndAddFieldValue(String type, String fieldValue, String fieldName, String errorMessage, JsonNode tmp) throws IllegalAccessException {
    // Add count variable for loop....
    final ObjectMapper mapper = new ObjectMapper();
    final ObjectNode parameter = mapper.createObjectNode();
    parameter.put("type", type);
    if (type == "int") {
        parameter.put("defaultValue", Integer.parseInt(fieldValue));
    } else {
        parameter.put("defaultValue", fieldValue);
    }
    ObjectNode.class.cast(tmp.get("parameters")).replace(fieldName, parameter);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)769 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)185 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)167 JsonNode (com.fasterxml.jackson.databind.JsonNode)165 Test (org.junit.Test)112 StringEntity (org.apache.http.entity.StringEntity)88 Deployment (org.activiti.engine.test.Deployment)84 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)67 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)64 Task (org.activiti.engine.task.Task)49 HttpPost (org.apache.http.client.methods.HttpPost)49 JCodeModel (com.sun.codemodel.JCodeModel)45 JPackage (com.sun.codemodel.JPackage)44 IOException (java.io.IOException)44 HttpPut (org.apache.http.client.methods.HttpPut)40 JType (com.sun.codemodel.JType)39 HashMap (java.util.HashMap)39 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)39 Map (java.util.Map)33 ArrayList (java.util.ArrayList)32