RemoteProcessImageServiceImpl extends AbstractKieServerService implements ProcessImageService { @Override public String getProcessInstanceDiagram(String serverTemplateId, String containerId, Long processInstanceId, String completedNodeColor, String completedNodeBorderColor, String activeNodeBorderColor) { UIServicesClient uiServicesClient = getClient(serverTemplateId, containerId, UIServicesClient.class); try { return removeActionsFromSVG(uiServicesClient.getProcessInstanceImageCustomColor(containerId, processInstanceId, completedNodeColor, completedNodeBorderColor, activeNodeBorderColor)); } catch (KieServicesHttpException ex) { LOGGER.warn("Failed to retrieve process instance image: {}", ex.getMessage()); if (ex.getHttpCode() == 404) { return null; } else { throw ex; } } }  @Override String getProcessInstanceDiagram(String serverTemplateId,
                                            String containerId,
                                            Long processInstanceId,
                                            String completedNodeColor,
                                            String completedNodeBorderColor,
                                            String activeNodeBorderColor); @Override String getProcessDiagram(String serverTemplateId,
                                    String containerId,
                                    String processId);  }
@Test public void testProcessInstanceImageHTML() { when(uiServicesClient.getProcessInstanceImageCustomColor("", null, "", "", "")) .thenReturn(SVG_WITH_ACTIONS, SVG_WITHOUT_ACTIONS); validateHTMLContent(service.getProcessInstanceDiagram("", "", null, "", "", "")); validateHTMLContent(service.getProcessInstanceDiagram("", "", null, "", "", "")); }
@Test public void testImageWithLink() { when(uiServicesClient.getProcessInstanceImageCustomColor("", null, "", "", "")).thenReturn(SVG_WITH_LINK); final String diagram = service.getProcessInstanceDiagram("", "", null, "", "", ""); assertFalse(diagram.contains("onclick")); assertEquals(SVG_WITHOUT_LINK, diagram); }
@Test public void testProcessInstanceImageNotFound() { final Integer okCode = 400; when(uiServicesClient.getProcessInstanceImageCustomColor("", null, "", "", "")) .thenThrow(new KieServicesHttpException(null, 404, null, null), new KieServicesHttpException(null, okCode, null, null)); assertNull(service.getProcessInstanceDiagram("", "", null, "", "", "")); try { service.getProcessInstanceDiagram("", "", null, "", "", ""); fail("Method should throw exception"); } catch (KieServicesHttpException ex) { assertEquals(okCode, ex.getHttpCode()); } }
@Test public void testProcessInstanceImageCustomColors() { String completeNodeColor = "#888888"; String completeNodeBorderColor = "#888887"; String activeNodeBorderColor = "#888886"; service.getProcessInstanceDiagram("", "", null, completeNodeColor, completeNodeBorderColor, activeNodeBorderColor); verify(uiServicesClient).getProcessInstanceImageCustomColor("", null, completeNodeColor, completeNodeBorderColor, activeNodeBorderColor); }