@Test
public void testUpdateAndCalculateRule() throws Exception {

	DDMForm ddmForm = new DDMForm();
	ddmForm.addDDMFormField(
		createDDMFormField("field0", "numeric", FieldConstants.DOUBLE));
	ddmForm.addDDMFormField(
		createDDMFormField("field1", "numeric", FieldConstants.DOUBLE));
	ddmForm.addDDMFormField(
		createDDMFormField("field2", "numeric", FieldConstants.DOUBLE));
	ddmForm.addDDMFormRule(
		new DDMFormRule(
			Arrays.asList(
				"calculate(\"field2\", getValue(\"field0\") * " +
					"getValue(\"field1\"))"),
			"getValue(\"field0\") > 0 && getValue(\"field1\") > 0"));
	DDMFormValues ddmFormValues = DDMFormValuesTestUtil.createDDMFormValues(
		ddmForm);
	ddmFormValues.addDDMFormFieldValue(
		DDMFormValuesTestUtil.createDDMFormFieldValue(
			"field0_instanceId", "field0", new UnlocalizedValue("5")));
	ddmFormValues.addDDMFormFieldValue(
		DDMFormValuesTestUtil.createDDMFormFieldValue(
			"field1_instanceId", "field1", new UnlocalizedValue("2")));
	ddmFormValues.addDDMFormFieldValue(
		DDMFormValuesTestUtil.createDDMFormFieldValue(
			"field2_instanceId", "field2", new UnlocalizedValue("0")));
	DDMFormEvaluatorEvaluateResponse ddmFormEvaluatorEvaluateResponse =
		doEvaluate(ddmForm, ddmFormValues);
	Map<DDMFormEvaluatorFieldContextKey, Map<String, Object>>
		ddmFormFieldsPropertyChanges =
			ddmFormEvaluatorEvaluateResponse.
				getDDMFormFieldsPropertyChanges();
	Assert.assertEquals(
		ddmFormFieldsPropertyChanges.toString(), 1,
		ddmFormFieldsPropertyChanges.size());
	// Field 0
	Assert.assertNull(
		ddmFormFieldsPropertyChanges.get(
			new DDMFormEvaluatorFieldContextKey(
				"field0", "field0_instanceId")));
	// Field 1
	Assert.assertNull(
		ddmFormFieldsPropertyChanges.get(
			new DDMFormEvaluatorFieldContextKey(
				"field1", "field1_instanceId")));
	// Field 2
	Map<String, Object> ddmFormFieldPropertyChanges =
		ddmFormFieldsPropertyChanges.get(
			new DDMFormEvaluatorFieldContextKey(
				"field2", "field2_instanceId"));
	Assert.assertEquals(
		ddmFormFieldPropertyChanges.toString(), 1,
		ddmFormFieldPropertyChanges.size());
	Assert.assertEquals(
		ddmFormFieldPropertyChanges.toString(), new BigDecimal(10.0),
		ddmFormFieldPropertyChanges.get("value"));
}