DDMFormInstanceRecordVersionModelListener extends BaseModelListener<DDMFormInstanceRecordVersion> { @Override public void onBeforeUpdate( DDMFormInstanceRecordVersion ddmFormInstanceRecordVersion) throws ModelListenerException { try { if (ddmFormInstanceRecordVersion.getStatus() != WorkflowConstants.STATUS_APPROVED) { return; } DDMFormInstanceRecordVersion latestDDMFormInstanceRecordVersion = _ddmFormInstanceRecordVersionLocalService. getLatestFormInstanceRecordVersion( ddmFormInstanceRecordVersion.getFormInstanceRecordId(), WorkflowConstants.STATUS_APPROVED); _processFormInstanceReportEvent( latestDDMFormInstanceRecordVersion, DDMFormInstanceReportConstants.EVENT_DELETE_RECORD_VERSION); } catch (Exception exception) { if (_log.isWarnEnabled()) { StringBundler sb = new StringBundler(4); sb.append("Unable to update dynamic data mapping form "); sb.append("instance report for dynamic data mapping form "); sb.append("instance record "); sb.append( ddmFormInstanceRecordVersion.getFormInstanceRecordId()); _log.warn(sb.toString(), exception); } } }  @Override void onAfterUpdate(
			DDMFormInstanceRecordVersion ddmFormInstanceRecordVersion); @Override void onBeforeUpdate(
			DDMFormInstanceRecordVersion ddmFormInstanceRecordVersion);  }
@Test public void testOnBeforeUpdate() throws PortalException { when( _ddmFormInstanceReportLocalService. getFormInstanceReportByFormInstanceId(Mockito.anyLong()) ).thenThrow( new NoSuchFormInstanceReportException() ); DDMFormInstanceRecordVersion ddmFormInstanceRecordVersion = mock( DDMFormInstanceRecordVersion.class); when( ddmFormInstanceRecordVersion.getFormInstanceId() ).thenReturn( 0L ); when( ddmFormInstanceRecordVersion.getStatus() ).thenReturn( WorkflowConstants.STATUS_APPROVED ); _ddmFormInstanceRecordVersionModelListener.onBeforeUpdate( ddmFormInstanceRecordVersion); }