FormServiceEntryPointImpl extends AbstractKieServerService implements FormServiceEntryPoint { @Override public FormRenderingSettings getFormDisplayTask(String serverTemplateId, String domainId, long taskId) { if (kieServerFormRenderer) { return getKieServerFormDisplayTask(serverTemplateId, domainId, taskId); } else { return getEmbeddedFormDisplayTask(serverTemplateId, domainId, taskId); } } @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 testRenderTaskForm() { formContent = FormContentReader.getTaskForms(); when(uiServicesClient.getTaskRawForm(anyString(), anyLong())).thenReturn(formContent); FormRenderingSettings settings = serviceEntryPoint.getFormDisplayTask("template", "domain", 12); verify(userTaskServicesClient).getTaskInstance(anyString(), anyLong(), anyBoolean(), anyBoolean(), anyBoolean()); verify(kieServicesClient).getClassLoader(); verify(uiServicesClient).getTaskRawForm(anyString(), anyLong()); verify(defaultProvider, never()).render(any(TaskRenderingSettings.class)); checkRenderingSettings(settings); }
@Test public void testRenderTaskDefaultForm() { FormRenderingSettings settings = serviceEntryPoint.getFormDisplayTask("template", "domain", 12); verify(userTaskServicesClient).getTaskInstance(anyString(), anyLong(), anyBoolean(), anyBoolean(), anyBoolean()); verify(kieServicesClient, times(2)).getClassLoader(); verify(uiServicesClient).getTaskRawForm(anyString(), anyLong()); verify(defaultProvider).render(any(TaskRenderingSettings.class)); checkRenderingSettings(settings); }
@Test(expected = TaskFormPermissionDeniedException.class) public void testRenderTaskFormWithPermissionException() { when(uiServicesClient.getTaskRawForm(anyString(), anyLong())) .thenThrow(new KieServicesHttpException("", Response.Status.UNAUTHORIZED.getStatusCode(), "", "")); FormRenderingSettings settings = serviceEntryPoint.getFormDisplayTask("template", "domain", 12); verify(userTaskServicesClient).getTaskInstance(anyString(), anyLong(), anyBoolean(), anyBoolean(), anyBoolean()); verify(kieServicesClient, times(2)).getClassLoader(); verify(uiServicesClient).getTaskRawForm(anyString(), anyLong()); checkRenderingSettings(settings); }
@Test public void testRenderTaskFormWithException() { when(uiServicesClient.getTaskRawForm(anyString(), anyLong())).thenThrow(new RuntimeException("Unable to find form")); FormRenderingSettings settings = serviceEntryPoint.getFormDisplayTask("template", "domain", 12); verify(userTaskServicesClient).getTaskInstance(anyString(), anyLong(), anyBoolean(), anyBoolean(), anyBoolean()); verify(kieServicesClient).getClassLoader(); verify(uiServicesClient).getTaskRawForm(anyString(), anyLong()); verify(defaultProvider).render(any(TaskRenderingSettings.class)); checkRenderingSettings(settings); }
@Test public void testRenderTaskDefaultFormWithException() { when(uiServicesClient.getTaskRawForm(anyString(), anyLong())).thenThrow(new KieServicesException("Unable to find form")); FormRenderingSettings settings = serviceEntryPoint.getFormDisplayTask("template", "domain", 12); verify(userTaskServicesClient).getTaskInstance(anyString(), anyLong(), anyBoolean(), anyBoolean(), anyBoolean()); verify(kieServicesClient).getClassLoader(); verify(uiServicesClient).getTaskRawForm(anyString(), anyLong()); verify(defaultProvider).render(any(TaskRenderingSettings.class)); checkRenderingSettings(settings); }
@Test public void testRenderTaskFormFromWrongFormContent() { formContent = "this form content is wrong and a default form should be generated"; when(uiServicesClient.getTaskRawForm(anyString(), anyLong())).thenReturn(formContent); FormRenderingSettings settings = serviceEntryPoint.getFormDisplayTask("template", "domain", 12); verify(userTaskServicesClient).getTaskInstance(anyString(), anyLong(), anyBoolean(), anyBoolean(), anyBoolean()); verify(kieServicesClient, times(2)).getClassLoader(); verify(uiServicesClient).getTaskRawForm(anyString(), anyLong()); checkRenderingSettings(settings); }