@Test public void testCheckModelSource() { when(finderService.getModelForProcess(any(), any())).thenReturn(getFullProcessModel()); Assertions.assertThatCode(() -> handler.checkSourceModel()) .doesNotThrowAnyException(); when(finderService.getModelForProcess(any(), any())).thenReturn(null); Assertions.assertThatThrownBy(() -> handler.checkSourceModel()) .isInstanceOf(SourceFormModelNotFoundException.class); when(finderService.getModelForProcess(any(), any())).thenReturn(getBaseProcessModel()); Assertions.assertThatThrownBy(() -> handler.checkSourceModel()) .isInstanceOf(SourceFormModelNotFoundException.class); }
@Override public void checkSourceModel() throws SourceFormModelNotFoundException { JBPMProcessModel processModel = bpmFinderService.getModelForProcess(formModel.getProcessId(), path); if (processModel != null) { Optional<TaskFormModel> optional = processModel.getTaskFormModels().stream() .filter(taskFormModel -> taskFormModel.getFormName().equals(formModel.getFormName())) .findAny(); if (!optional.isPresent()) { String[] params = new String[]{formModel.getTaskName(), formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_TASK_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_TASK_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } } else { String[] params = new String[]{formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } }
TaskFormModelHandler extends AbstractJBPMFormModelHandler<TaskFormModel> { @Override public void checkSourceModel() throws SourceFormModelNotFoundException { JBPMProcessModel processModel = bpmFinderService.getModelForProcess(formModel.getProcessId(), path); if (processModel != null) { Optional<TaskFormModel> optional = processModel.getTaskFormModels().stream() .filter(taskFormModel -> taskFormModel.getFormName().equals(formModel.getFormName())) .findAny(); if (!optional.isPresent()) { String[] params = new String[]{formModel.getTaskName(), formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_TASK_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_TASK_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } } else { String[] params = new String[]{formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } } }
TaskFormModelHandler extends AbstractJBPMFormModelHandler<TaskFormModel> { @Override public void checkSourceModel() throws SourceFormModelNotFoundException { JBPMProcessModel processModel = bpmFinderService.getModelForProcess(formModel.getProcessId(), path); if (processModel != null) { Optional<TaskFormModel> optional = processModel.getTaskFormModels().stream() .filter(taskFormModel -> taskFormModel.getFormName().equals(formModel.getFormName())) .findAny(); if (!optional.isPresent()) { String[] params = new String[]{formModel.getTaskName(), formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_TASK_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_TASK_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } } else { String[] params = new String[]{formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } } @Inject  TaskFormModelHandler(KieModuleService projectService,
                                ModuleClassLoaderHelper classLoaderHelper,
                                FieldManager fieldManager,
                                BPMFinderService bpmFinderService); }
TaskFormModelHandler extends AbstractJBPMFormModelHandler<TaskFormModel> { @Override public void checkSourceModel() throws SourceFormModelNotFoundException { JBPMProcessModel processModel = bpmFinderService.getModelForProcess(formModel.getProcessId(), path); if (processModel != null) { Optional<TaskFormModel> optional = processModel.getTaskFormModels().stream() .filter(taskFormModel -> taskFormModel.getFormName().equals(formModel.getFormName())) .findAny(); if (!optional.isPresent()) { String[] params = new String[]{formModel.getTaskName(), formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_TASK_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_TASK_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } } else { String[] params = new String[]{formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } } @Inject  TaskFormModelHandler(KieModuleService projectService,
                                ModuleClassLoaderHelper classLoaderHelper,
                                FieldManager fieldManager,
                                BPMFinderService bpmFinderService); @Override Class<TaskFormModel> getModelType(); @Override void checkSourceModel(); @Override FormModelHandler<TaskFormModel> newInstance(); }
TaskFormModelHandler extends AbstractJBPMFormModelHandler<TaskFormModel> { @Override public void checkSourceModel() throws SourceFormModelNotFoundException { JBPMProcessModel processModel = bpmFinderService.getModelForProcess(formModel.getProcessId(), path); if (processModel != null) { Optional<TaskFormModel> optional = processModel.getTaskFormModels().stream() .filter(taskFormModel -> taskFormModel.getFormName().equals(formModel.getFormName())) .findAny(); if (!optional.isPresent()) { String[] params = new String[]{formModel.getTaskName(), formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_TASK_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_TASK_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } } else { String[] params = new String[]{formModel.getProcessId()}; throw new SourceFormModelNotFoundException(JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_SHORT_KEY, params, JBPMFormsIntegrationBackendConstants.MISSING_PROCESS_FULL_KEY, params, JBPMFormsIntegrationBackendConstants.PROCESS_KEY, formModel); } } @Inject  TaskFormModelHandler(KieModuleService projectService,
                                ModuleClassLoaderHelper classLoaderHelper,
                                FieldManager fieldManager,
                                BPMFinderService bpmFinderService); @Override Class<TaskFormModel> getModelType(); @Override void checkSourceModel(); @Override FormModelHandler<TaskFormModel> newInstance();  }