*
*/
public class TestConnectionBean {
@Test
public void testSerialization() {
MConnection connection = getConnection("ahoj");
connection.setName("Connection");
connection.setPersistenceId(666);
// Fill some data at the beginning
MStringInput input = (MStringInput) connection.getConnectorPart().getForms()
.get(0).getInputs().get(0);
input.setValue("Hi there!");
// Serialize it to JSON object
ConnectionBean bean = new ConnectionBean(connection);
JSONObject json = bean.extract();
// "Move" it across network in text form
String string = json.toJSONString();
// Retrieved transferred object
JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
ConnectionBean retrievedBean = new ConnectionBean();
retrievedBean.restore(retrievedJson);
MConnection target = retrievedBean.getConnections().get(0);
// Check id and name
assertEquals(666, target.getPersistenceId());
assertEquals("Connection", target.getName());
// Test that value was correctly moved
MStringInput targetInput = (MStringInput) target.getConnectorPart()
.getForms().get(0).getInputs().get(0);
assertEquals("Hi there!", targetInput.getValue());
}