use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.
the class AbstractEmptyBodyFilterTest method evaluatePostRequest.
private void evaluatePostRequest(HttpEntity reqBody, String reqContentType, int expectedStatusCode, boolean assertResponseBody) throws IOException {
HttpPost post = new HttpPost(BASE_URL + START_PROCESS_INSTANCE_BY_KEY_URL);
post.setConfig(reqConfig);
if (reqContentType != null) {
post.setHeader(HttpHeaders.CONTENT_TYPE, reqContentType);
}
post.setEntity(reqBody);
CloseableHttpResponse response = client.execute(post);
assertEquals(expectedStatusCode, response.getStatusLine().getStatusCode());
if (assertResponseBody) {
assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, new JSONObject(EntityUtils.toString(response.getEntity(), "UTF-8")).get("id"));
}
response.close();
}
use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.
the class SetJobRetriesBatchConfigurationJsonConverter method toJsonObject.
public JSONObject toJsonObject(SetRetriesBatchConfiguration configuration) {
JSONObject json = new JSONObject();
JsonUtil.addListField(json, JOB_IDS, configuration.getIds());
JsonUtil.addField(json, RETRIES, configuration.getRetries());
return json;
}
use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.
the class AbstractBatchJobHandler method writeConfiguration.
@Override
public byte[] writeConfiguration(T configuration) {
JSONObject jsonObject = getJsonConverterInstance().toJsonObject(configuration);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
Writer writer = StringUtil.writerForStream(outStream);
jsonObject.write(writer);
IoUtil.flushSilently(writer);
return outStream.toByteArray();
}
use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.
the class DeleteHistoricProcessInstanceBatchConfigurationJsonConverter method readProcessInstanceIds.
protected List<String> readProcessInstanceIds(JSONObject jsonObject) {
List<Object> objects = JsonUtil.jsonArrayAsList(jsonObject.getJSONArray(HISTORIC_PROCESS_INSTANCE_IDS));
List<String> processInstanceIds = new ArrayList<String>();
for (Object object : objects) {
processInstanceIds.add((String) object);
}
return processInstanceIds;
}
use of org.camunda.bpm.engine.impl.util.json.JSONObject in project camunda-bpm-platform by camunda.
the class JsonUtilTest method testJsonObjectToMap.
@Test
@SuppressWarnings("unchecked")
public void testJsonObjectToMap() {
assertNull(jsonObjectAsMap(null));
JSONObject jsonObject = new JSONObject();
Map<String, Object> map = jsonObjectAsMap(jsonObject);
assertTrue(map.isEmpty());
jsonObject.put("boolean", true);
jsonObject.put("int", 12);
jsonObject.put("double", 11.1);
jsonObject.put("long", 13l);
jsonObject.put("string", "test");
jsonObject.put("list", Collections.singletonList("test"));
jsonObject.put("map", Collections.singletonMap("test", "test"));
jsonObject.put("date", new Date(0));
jsonObject.put("null", JSONObject.NULL);
map = jsonObjectAsMap(jsonObject);
assertEquals(9, map.size());
assertEquals(true, map.get("boolean"));
assertEquals(12, map.get("int"));
assertEquals(11.1, map.get("double"));
assertEquals(13l, map.get("long"));
assertEquals("test", map.get("string"));
List<Object> embeddedList = (List<Object>) map.get("list");
assertEquals(1, embeddedList.size());
assertEquals("test", embeddedList.get(0));
Map<String, Object> embeddedMap = (Map<String, Object>) map.get("map");
assertEquals(1, embeddedMap.size());
assertTrue(embeddedMap.containsKey("test"));
assertEquals("test", embeddedMap.get("test"));
Date embeddedDate = (Date) map.get("date");
assertEquals(new Date(0), embeddedDate);
assertTrue(map.containsKey("null"));
assertNull(map.get("null"));
}
Aggregations