job.setPersistenceId(666);
job.setCreationDate(created);
job.setLastUpdateDate(updated);
// Fill some data at the beginning
MStringInput input = (MStringInput) job.getConnectorPart().getForms()
.get(0).getInputs().get(0);
input.setValue("Hi there!");
// Serialize it to JSON object
JobBean bean = new JobBean(job);
JSONObject json = bean.extract(false);
// "Move" it across network in text form
String string = json.toJSONString();
// Retrieved transferred object
JSONObject retrievedJson = (JSONObject)JSONValue.parseWithException(string);
JobBean retrievedBean = new JobBean();
retrievedBean.restore(retrievedJson);
MJob target = retrievedBean.getJobs().get(0);
// Check id and name
assertEquals(666, target.getPersistenceId());
assertEquals(MJob.Type.IMPORT, target.getType());
assertEquals("The big job", target.getName());
assertEquals(created, target.getCreationDate());
assertEquals(updated, target.getLastUpdateDate());
// Test that value was correctly moved
MStringInput targetInput = (MStringInput) target.getConnectorPart()
.getForms().get(0).getInputs().get(0);
assertEquals("Hi there!", targetInput.getValue());
}