@Test
public void testProcessDDMFormInstanceReportOnDeleteEvent()
	throws Exception {

	DDMFormFieldValue ddmFormFieldValue = _mockDDMFormFieldValue(
		"field1", "3");
	long formInstanceRecordId = 3;
	DDMFormInstanceRecord ddmFormInstanceRecord =
		_mockDDMFormInstanceRecord(formInstanceRecordId);
	DDMFormInstance ddmFormInstance = mock(DDMFormInstance.class);
	when(
		ddmFormInstance.getFormInstanceId()
	).thenReturn(
		0L
	);
	List<DDMFormInstanceRecord> ddmFormInstanceRecords = new ArrayList<>();
	for (int i = _VALUES_MAX_LENGTH; i > 0; i--) {
		ddmFormInstanceRecords.add(
			_createDDMFormInstanceRecord(String.valueOf(i)));
	}
	when(
		ddmFormInstance.getFormInstanceRecords()
	).thenReturn(
		ddmFormInstanceRecords
	);
	when(
		ddmFormInstanceRecord.getFormInstance()
	).thenReturn(
		ddmFormInstance
	);
	when(
		_ddmFormInstanceRecordLocalService.searchFormInstanceRecords(
			Mockito.eq(0L), Mockito.eq(new String[] {"field1"}),
			Mockito.eq(WorkflowConstants.STATUS_APPROVED), Mockito.eq(0),
			Mockito.eq(_VALUES_MAX_LENGTH + 1), Mockito.any())
	).thenReturn(
		new BaseModelSearchResult<DDMFormInstanceRecord>(
			ddmFormInstanceRecords, ddmFormInstanceRecords.size())
	);
	JSONObject processedFieldJSONObject =
		_numericDDMFormFieldTypeReportProcessor.process(
			ddmFormFieldValue,
			JSONUtil.put(
				"summary",
				JSONUtil.put(
					"average", "3"
				).put(
					"max", "5"
				).put(
					"min", "1"
				).put(
					"sum", "15"
				)
			).put(
				"totalEntries", 5
			).put(
				"type", DDMFormFieldType.NUMERIC
			).put(
				"values",
				JSONUtil.putAll(
					JSONUtil.put(
						"formInstanceRecordId", 5
					).put(
						"value", "5"
					),
					JSONUtil.put(
						"formInstanceRecordId", 4
					).put(
						"value", "4"
					),
					JSONUtil.put(
						"formInstanceRecordId", 3
					).put(
						"value", "3"
					),
					JSONUtil.put(
						"formInstanceRecordId", 2
					).put(
						"value", "2"
					),
					JSONUtil.put(
						"formInstanceRecordId", 1
					).put(
						"value", "1"
					))
			),
			formInstanceRecordId,
			DDMFormInstanceReportConstants.EVENT_DELETE_RECORD_VERSION);
	JSONObject summaryJSONObject = processedFieldJSONObject.getJSONObject(
		"summary");
	Assert.assertEquals("3", summaryJSONObject.getString("average"));
	Assert.assertEquals("5", summaryJSONObject.getString("max"));
	Assert.assertEquals("1", summaryJSONObject.getString("min"));
	Assert.assertEquals("12", summaryJSONObject.getString("sum"));
}