Search in sources :

Example 76 with ObjectNode

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

the class BaseBpmnJsonConverter method addFormProperties.

protected void addFormProperties(List<FormProperty> formProperties, ObjectNode propertiesNode) {
    if (CollectionUtils.isEmpty(formProperties))
        return;
    ObjectNode formPropertiesNode = objectMapper.createObjectNode();
    ArrayNode propertiesArrayNode = objectMapper.createArrayNode();
    for (FormProperty property : formProperties) {
        ObjectNode propertyItemNode = objectMapper.createObjectNode();
        propertyItemNode.put(PROPERTY_FORM_ID, property.getId());
        propertyItemNode.put(PROPERTY_FORM_NAME, property.getName());
        propertyItemNode.put(PROPERTY_FORM_TYPE, property.getType());
        if (StringUtils.isNotEmpty(property.getExpression())) {
            propertyItemNode.put(PROPERTY_FORM_EXPRESSION, property.getExpression());
        } else {
            propertyItemNode.putNull(PROPERTY_FORM_EXPRESSION);
        }
        if (StringUtils.isNotEmpty(property.getVariable())) {
            propertyItemNode.put(PROPERTY_FORM_VARIABLE, property.getVariable());
        } else {
            propertyItemNode.putNull(PROPERTY_FORM_VARIABLE);
        }
        if (StringUtils.isNotEmpty(property.getDatePattern())) {
            propertyItemNode.put(PROPERTY_FORM_DATE_PATTERN, property.getDatePattern());
        }
        if (CollectionUtils.isNotEmpty(property.getFormValues())) {
            ArrayNode valuesNode = objectMapper.createArrayNode();
            for (FormValue formValue : property.getFormValues()) {
                ObjectNode valueNode = objectMapper.createObjectNode();
                valueNode.put(PROPERTY_FORM_ENUM_VALUES_NAME, formValue.getName());
                valueNode.put(PROPERTY_FORM_ENUM_VALUES_ID, formValue.getId());
                valuesNode.add(valueNode);
            }
            propertyItemNode.put(PROPERTY_FORM_ENUM_VALUES, valuesNode);
        }
        propertyItemNode.put(PROPERTY_FORM_REQUIRED, property.isRequired());
        propertyItemNode.put(PROPERTY_FORM_READABLE, property.isReadable());
        propertyItemNode.put(PROPERTY_FORM_WRITABLE, property.isWriteable());
        propertiesArrayNode.add(propertyItemNode);
    }
    formPropertiesNode.put("formProperties", propertiesArrayNode);
    propertiesNode.put(PROPERTY_FORM_PROPERTIES, formPropertiesNode);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) FormValue(org.activiti.bpmn.model.FormValue) FormProperty(org.activiti.bpmn.model.FormProperty) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 77 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project jackson-databind by FasterXML.

the class NullSerializationTest method testCustomNullForTrees.

// #281
public void testCustomNullForTrees() throws Exception {
    ObjectNode root = MAPPER.createObjectNode();
    root.putNull("a");
    // by default, null is... well, null
    assertEquals("{\"a\":null}", MAPPER.writeValueAsString(root));
    // but then we can customize it:
    DefaultSerializerProvider prov = new MyNullProvider();
    prov.setNullValueSerializer(new NullSerializer());
    ObjectMapper m = new ObjectMapper();
    m.setSerializerProvider(prov);
    assertEquals("{\"a\":\"foobar\"}", m.writeValueAsString(root));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)

Example 78 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project Rosetta by HubSpot.

the class StoredAsJsonTest method testJsonNodeFieldDeserialization.

@Test
public void testJsonNodeFieldDeserialization() throws JsonProcessingException {
    ObjectNode node = Rosetta.getMapper().createObjectNode();
    node.put("jsonNodeField", expected);
    StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
    assertThat(bean.getJsonNodeField()).isEqualTo(innerJsonNode);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) StoredAsJsonBean(com.hubspot.rosetta.beans.StoredAsJsonBean) Test(org.junit.Test)

Example 79 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project Rosetta by HubSpot.

the class StoredAsJsonTest method testAnnotatedFieldWithDefaultNullDeserialization.

@Test
public void testAnnotatedFieldWithDefaultNullDeserialization() throws JsonProcessingException {
    ObjectNode node = Rosetta.getMapper().createObjectNode();
    node.put("annotatedFieldWithDefault", NullNode.getInstance());
    StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
    assertThat(bean.getAnnotatedFieldWithDefault().getStringProperty()).isEqualTo("value");
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) StoredAsJsonBean(com.hubspot.rosetta.beans.StoredAsJsonBean) Test(org.junit.Test)

Example 80 with ObjectNode

use of com.fasterxml.jackson.databind.node.ObjectNode in project Rosetta by HubSpot.

the class StoredAsJsonTest method testAnnotatedFieldWithDefaultDeserialization.

@Test
public void testAnnotatedFieldWithDefaultDeserialization() throws JsonProcessingException {
    ObjectNode node = Rosetta.getMapper().createObjectNode();
    node.put("annotatedFieldWithDefault", expected);
    StoredAsJsonBean bean = Rosetta.getMapper().treeToValue(node, StoredAsJsonBean.class);
    assertThat(bean.getAnnotatedFieldWithDefault().getStringProperty()).isEqualTo("value");
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) StoredAsJsonBean(com.hubspot.rosetta.beans.StoredAsJsonBean) Test(org.junit.Test)

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