DDMFormInstanceRecordModelListener extends BaseModelListener<DDMFormInstanceRecord> { @Override public void onBeforeRemove(DDMFormInstanceRecord ddmFormInstanceRecord) throws ModelListenerException { try { DDMFormInstanceReport ddmFormInstanceReport = ddmFormInstanceReportLocalService. getFormInstanceReportByFormInstanceId( ddmFormInstanceRecord.getFormInstanceId()); DDMFormInstanceRecordVersion ddmFormInstanceRecordVersion = ddmFormInstanceRecord.getLatestFormInstanceRecordVersion(); ddmFormInstanceReportLocalService.processFormInstanceReportEvent( ddmFormInstanceReport.getFormInstanceReportId(), ddmFormInstanceRecordVersion.getFormInstanceRecordVersionId(), 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(ddmFormInstanceRecord.getFormInstanceRecordId()); _log.warn(sb.toString(), exception); } } }  @Override void onBeforeRemove(DDMFormInstanceRecord ddmFormInstanceRecord);  }
@Test public void testOnBeforeRemove() throws PortalException { when( _ddmFormInstanceReportLocalService. getFormInstanceReportByFormInstanceId(Mockito.anyLong()) ).thenThrow( new NoSuchFormInstanceReportException() ); DDMFormInstanceRecord ddmFormInstanceRecord = mock( DDMFormInstanceRecord.class); when( ddmFormInstanceRecord.getFormInstanceId() ).thenReturn( 0L ); _ddmFormInstanceRecordModelListener.onBeforeRemove( ddmFormInstanceRecord); }