DDMFormInstanceModelListener extends BaseModelListener<DDMFormInstance> { @Override public void onAfterCreate(DDMFormInstance ddmFormInstance) throws ModelListenerException { try { ddmFormInstanceReportLocalService.addFormInstanceReport( ddmFormInstance.getFormInstanceId()); } 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 "); sb.append(ddmFormInstance.getFormInstanceId()); _log.warn(sb.toString(), exception); } } }  @Override void onAfterCreate(DDMFormInstance ddmFormInstance); @Override void onBeforeRemove(DDMFormInstance ddmFormInstance);  }
@Test public void testOnAfterCreate() throws PortalException { when( _ddmFormInstanceReportLocalService.addFormInstanceReport( Mockito.anyLong()) ).thenThrow( new NoSuchFormInstanceException() ); DDMFormInstance ddmFormInstance = mock(DDMFormInstance.class); when( ddmFormInstance.getFormInstanceId() ).thenReturn( 0L ); _ddmFormInstanceModelListener.onAfterCreate(ddmFormInstance); }