FormServiceEntryPointImpl extends AbstractKieServerService implements FormServiceEntryPoint { @Override public FormRenderingSettings getFormDisplayProcess(String serverTemplateId, String domainId, String processId, boolean isDynamic) { if (kieServerFormRenderer) { return getKieServerFormDisplayProcess(serverTemplateId, domainId, processId, isDynamic); } else { return getEmbeddedFormDisplayProcess(serverTemplateId, domainId, processId); } } @Inject  FormServiceEntryPointImpl(Instance<FormProvider<? extends FormRenderingSettings>> providersInjected,
                                     @DefaultFormProvider FormProvider<? extends FormRenderingSettings> defaultFormProvider); @Override FormRenderingSettings getFormDisplayTask(String serverTemplateId,
                                                    String domainId,
                                                    long taskId); @Override FormRenderingSettings getFormDisplayProcess(String serverTemplateId,
                                                       String domainId,
                                                       String processId,
                                                       boolean isDynamic);  }
@Test public void testRenderProcessForm() { formContent = FormContentReader.getStartProcessForms(); when(uiServicesClient.getProcessRawForm(anyString(), anyString())).thenReturn(formContent); FormRenderingSettings settings = serviceEntryPoint.getFormDisplayProcess("template", "domain", "invoices", false); verify(processServicesClient).getProcessDefinition(anyString(), anyString()); verify(kieServicesClient).getClassLoader(); verify(uiServicesClient).getProcessRawForm(anyString(), anyString()); verify(defaultProvider, never()).render(any(ProcessRenderingSettings.class)); checkRenderingSettings(settings); }
@Test public void testRenderProcessDefaultForm() { FormRenderingSettings settings = serviceEntryPoint.getFormDisplayProcess("template", "domain", "invoices", false); verify(processServicesClient).getProcessDefinition(anyString(), anyString()); verify(kieServicesClient, times(2)).getClassLoader(); verify(uiServicesClient).getProcessRawForm(anyString(), anyString()); verify(defaultProvider).render(any(ProcessRenderingSettings.class)); checkRenderingSettings(settings); }
@Test public void testRenderProcessFormFromWrongFormContent() { formContent = "this form content is wrong and a default form should be generated"; when(uiServicesClient.getProcessRawForm(anyString(), anyString())).thenReturn(formContent); FormRenderingSettings settings = serviceEntryPoint.getFormDisplayProcess("template", "domain", "invoices", false); verify(processServicesClient).getProcessDefinition(anyString(), anyString()); verify(kieServicesClient, times(2)).getClassLoader(); verify(uiServicesClient).getProcessRawForm(anyString(), anyString()); verify(defaultProvider).render(any(ProcessRenderingSettings.class)); checkRenderingSettings(settings); }
@Test public void testRenderProcessDefaultFormWithException() { when(uiServicesClient.getProcessRawForm(anyString(), anyString())).thenThrow(new KieServicesException("Unable to find form")); FormRenderingSettings settings = serviceEntryPoint.getFormDisplayProcess("template", "domain", "invoices", false); verify(processServicesClient).getProcessDefinition(anyString(), anyString()); verify(kieServicesClient).getClassLoader(); verify(uiServicesClient).getProcessRawForm(anyString(), anyString()); verify(defaultProvider).render(any(ProcessRenderingSettings.class)); checkRenderingSettings(settings); }