use of org.camunda.spin.json.SpinJsonNode in project camunda-bpm-platform by camunda.
the class JsonValueTest method testGetTypedJsonValue.
@Deployment(resources = ONE_TASK_PROCESS)
public void testGetTypedJsonValue() throws JSONException {
// given
JsonValue jsonValue = jsonValue(jsonString).create();
VariableMap variables = Variables.createVariables().putValueTyped(variableName, jsonValue);
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).getId();
// when
JsonValue typedValue = runtimeService.getVariableTyped(processInstanceId, variableName);
// then
SpinJsonNode value = typedValue.getValue();
JSONAssert.assertEquals(jsonString, value.toString(), true);
assertTrue(typedValue.isDeserialized());
assertEquals(JSON, typedValue.getType());
assertEquals(JSON_FORMAT_NAME, typedValue.getSerializationDataFormat());
JSONAssert.assertEquals(jsonString, typedValue.getValueSerialized(), true);
}
use of org.camunda.spin.json.SpinJsonNode in project camunda-bpm-platform by camunda.
the class JsonValueTest method testGetUntypedJsonValue.
@Deployment(resources = ONE_TASK_PROCESS)
public void testGetUntypedJsonValue() throws JSONException {
// given
JsonValue jsonValue = jsonValue(jsonString).create();
VariableMap variables = Variables.createVariables().putValueTyped(variableName, jsonValue);
String processInstanceId = runtimeService.startProcessInstanceByKey(ONE_TASK_PROCESS_KEY, variables).getId();
// when
SpinJsonNode value = (SpinJsonNode) runtimeService.getVariable(processInstanceId, variableName);
// then
JSONAssert.assertEquals(jsonString, value.toString(), true);
assertEquals(json().getName(), value.getDataFormatName());
}
use of org.camunda.spin.json.SpinJsonNode in project camunda-bpm-platform by camunda.
the class SpinFunctionMapperTest method testSpin_JSON_Available.
public void testSpin_JSON_Available() {
SpinJsonNode spinJsonEl = executeExpression("${ JSON('" + jsonString + "') }");
assertNotNull(spinJsonEl);
assertEquals("bar", spinJsonEl.prop("foo").stringValue());
}
use of org.camunda.spin.json.SpinJsonNode in project camunda-bpm-platform by camunda.
the class PaSpinSupportTest method testJacksonBug146.
@Test
public void testJacksonBug146() {
InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("org/camunda/bpm/integrationtest/functional/spin/jackson146.json");
String jackson146 = SpinIoUtil.inputStreamAsString(resourceAsStream);
// this should not fail
SpinJsonNode node = JSON(jackson146);
// file has 4000 characters in length a
// 20 characters per repeated JSON object
assertEquals(200, node.prop("abcdef").elements().size());
}
use of org.camunda.spin.json.SpinJsonNode in project camunda-bpm-platform by camunda.
the class SpinJsonPathDelegate method execute.
@Override
public void execute(DelegateExecution execution) throws Exception {
String json = "{\"child\": [{\"id\": 1,\"name\": \"Lucy\",\"sex\": \"female\"},{\"id\": 2,\"name\": \"Tracy\",\"sex\": \"female\"}],\"number\": 1,\"boolean\": true}";
SpinJsonNode spinJsonNode = JSON(json).jsonPath("$.child[0]").element();
if (spinJsonNode == null) {
throw new RuntimeException("Unable to evalute jsonpath");
}
}
Aggregations