### Question:
WorkItemDefinitionParser { public static Collection<WorkItemDefinition> parse(final String content, final Function<WorkDefinitionImpl, String> uriProvider, final Function<String, String> dataUriProvider) throws Exception { final Map<String, WorkDefinitionImpl> definitionMap = parseJBPMWorkItemDefinitions(content, dataUriProvider); return definitionMap.values().stream() .map(wid -> parse(wid, uriProvider, dataUriProvider)) .collect(Collectors.toList()); }  static Collection<WorkItemDefinition> parse(final String content,
                                                       final Function<WorkDefinitionImpl, String> uriProvider,
                                                       final Function<String, String> dataUriProvider); static WorkItemDefinition parse(final WorkDefinitionImpl workDefinition,
                                           final Function<WorkDefinitionImpl, String> uriProvider,
                                           final Function<String, String> dataUriProvider); static String buildDataURIFromURL(final String url); static final Map<Class<?>, Function<Object, String>> DATA_TYPE_FORMATTERS; static final String ENCODING; }### Answer:
@Test public void testParseJBPMWorkDefinition() { WorkItemDefinition workItemDefinition = WorkItemDefinitionParser.parse(jbpmWorkDefinition, w -> "uri", dataUriProvider); assertNotNull(workItemDefinition); assertEquals(NAME, workItemDefinition.getName()); assertEquals(CATWGORY, workItemDefinition.getCategory()); assertEquals(DESC, workItemDefinition.getDescription()); assertEquals(DISPLAY_NAME, workItemDefinition.getDisplayName()); assertEquals(DOC, workItemDefinition.getDocumentation()); assertEquals(HANDLER, workItemDefinition.getDefaultHandler()); assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData()); assertEquals("|param1:String,param2:String|", workItemDefinition.getParameters()); assertEquals("||", workItemDefinition.getResults()); }
@Test public void testEmailWorkItemDefinition() throws Exception { when(dataUriProvider.apply(eq("email.gif"))).thenReturn(ICON_DATA); String raw = loadStream(WID_EMAIL); Collection<WorkItemDefinition> workItemDefinitions = WorkItemDefinitionParser.parse(raw, w -> "uri", dataUriProvider); assertNotNull(workItemDefinitions); assertEquals(1, workItemDefinitions.size()); WorkItemDefinition workItemDefinition = workItemDefinitions.iterator().next(); assertNotNull(workItemDefinition); assertEquals("Email", workItemDefinition.getName()); assertEquals("Communication", workItemDefinition.getCategory()); assertEquals("Sending emails", workItemDefinition.getDescription()); assertEquals("Email", workItemDefinition.getDisplayName()); assertEquals("index.html", workItemDefinition.getDocumentation()); assertEquals("org.jbpm.process.workitem.email.EmailWorkItemHandler", workItemDefinition.getDefaultHandler()); assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData()); assertEquals("|Body:String,From:String,Subject:String,To:String|", workItemDefinition.getParameters()); assertEquals("||", workItemDefinition.getResults()); }
@Test public void testFTPWorkItemDefinition() throws Exception { when(dataUriProvider.apply(eq("ftp.gif"))).thenReturn(ICON_DATA); String raw = loadStream(WID_FTP); Collection<WorkItemDefinition> workItemDefinitions = WorkItemDefinitionParser.parse(raw, w -> "uri", dataUriProvider); assertNotNull(workItemDefinitions); assertEquals(1, workItemDefinitions.size()); WorkItemDefinition workItemDefinition = workItemDefinitions.iterator().next(); assertNotNull(workItemDefinition); assertEquals("FTP", workItemDefinition.getName()); assertEquals("File System", workItemDefinition.getCategory()); assertEquals("Sending files using FTP", workItemDefinition.getDescription()); assertEquals("FTP", workItemDefinition.getDisplayName()); assertEquals("", workItemDefinition.getDocumentation()); assertEquals("org.jbpm.process.workitem.ftp.FTPUploadWorkItemHandler", workItemDefinition.getDefaultHandler()); assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData()); assertEquals("|Body:String,FilePath:String,Password:String,User:String|", workItemDefinition.getParameters()); assertEquals("||", workItemDefinition.getResults()); }