}
@Test
public void testMarshalling() throws Exception {
ExpressionEditorMessageJSONMarshaller marshaller = new ExpressionEditorMessageJSONMarshaller();
ExpressionEditorMessage message = new ExpressionEditorMessage();
ConditionExpression expression = new ConditionExpression("OR");
message.setExpression(expression);
Condition condition1 = new Condition();
condition1.setFunction("isEquals");
condition1.getParameters().add("variableName1");
condition1.getParameters().add("param1.1");
expression.getConditions().add(condition1);
Condition condition2 = new Condition();
condition2.setFunction("isBetween");
condition2.getParameters().add("variableName2");
condition2.getParameters().add("param2.1");
condition2.getParameters().add("param2.2");
expression.getConditions().add(condition2);
message.setScript("return true;");
message.setErrorCode("The error code");
message.setErrorMessage("The error message");
String expectedResult = "{\"operator\":\"OR\"," +
"\"conditions\":[" +
"{" +
"\"condition\":\"isEquals\"," +
"\"parameters\":[\"variableName1\",\"param1.1\"]" +
"}," +
"{" +
"\"condition\":\"isBetween\"," +
"\"parameters\":[\"variableName2\",\"param2.1\",\"param2.2\"]" +
"}" +
"]," +
"\"script\":\"return true;\"," +
"\"errorCode\":\"The error code\"," +
"\"errorMessage\":\"The error message\"" +
"}";
String result = marshaller.marshall(message);
assertEquals(expectedResult, result);
}