use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class NoWIDCustomTaskResolutionTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
// Setup context.
widRegistry = new WorkItemDefinitionRegistry() {
@Override
public Collection<WorkItemDefinition> items() {
return Collections.EMPTY_LIST;
}
@Override
public WorkItemDefinition get(String name) {
return null;
}
};
widService = mock(WorkItemDefinitionLookupService.class);
when(widService.execute(any(Metadata.class))).thenReturn(widRegistry.items());
stunnerAPI = StunnerTestingGraphBackendAPI.build(BPMNDefinitionSet.class, new BPMNTestDefinitionFactory(widRegistry));
xmlEncoder = new XMLEncoderDiagramMetadataMarshaller();
// Setup tested instance.
tested = new BPMNDirectDiagramMarshaller(xmlEncoder, stunnerAPI.getDefinitionManager(), stunnerAPI.getRuleManager(), widService, stunnerAPI.getFactoryManager(), stunnerAPI.commandFactory, stunnerAPI.commandManager, dataTypeCacheServer);
diagram = Unmarshalling.unmarshall(tested, BPMN_CUSTOM_TASK);
}
use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class WorkItemDefinitionParserTest method testParseJBPMWorkDefinition.
@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());
}
use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class WorkItemDefinitionVFSLookupServiceTest method testExecute.
@Test
@SuppressWarnings("unchecked")
public void testExecute() {
Collection<WorkItemDefinition> result = tested.execute(metadata);
ArgumentCaptor<DirectoryStream.Filter> filterCaptor = ArgumentCaptor.forClass(DirectoryStream.Filter.class);
verify(vfsService, times(1)).newDirectoryStream(eq(path), any(DirectoryStream.Filter.class));
assertFalse(result.isEmpty());
assertEquals(1, result.size());
WorkItemDefinition wid = result.iterator().next();
assertEquals("Email", wid.getName());
}
use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class WorkItemDefinitionVFSLookupServiceTest method testFilter.
@Test
@SuppressWarnings("unchecked")
public void testFilter() {
Collection<WorkItemDefinition> result = tested.execute(metadata);
ArgumentCaptor<DirectoryStream.Filter> filterCaptor = ArgumentCaptor.forClass(DirectoryStream.Filter.class);
verify(vfsService, times(1)).newDirectoryStream(eq(path), filterCaptor.capture());
DirectoryStream.Filter<Path> filter = filterCaptor.getValue();
Path path1 = mock(Path.class);
when(path1.getFileName()).thenReturn("someFile.wid");
assertTrue(filter.accept(path1));
when(path1.getFileName()).thenReturn("someFile.bpmn");
assertFalse(filter.accept(path1));
when(path1.getFileName()).thenReturn("someFile.WID");
assertTrue(filter.accept(path1));
when(path1.getFileName()).thenReturn("someFile.WiD");
assertTrue(filter.accept(path1));
}
use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class WorkItemDefinitionClientParserTest method testWidParse.
private void testWidParse(final String wid) {
List<WorkItemDefinition> defs = WorkItemDefinitionClientParser.parse(wid);
assertEquals(4, defs.size());
WorkItemDefinition wid1 = defs.get(0);
assertEquals("Email", wid1.getName());
assertEquals("Display Email", wid1.getDisplayName());
assertEquals("defaultemailicon.gif", wid1.getIconDefinition().getUri());
assertEquals(BPMNCategories.CUSTOM_TASKS, wid1.getCategory());
assertEquals("Some documentation", wid1.getDocumentation());
assertTrue(wid1.getResults().isEmpty());
assertEquals(EMAIL_WID_EXTRACTED_PARAMETERS, wid1.getParameters());
WorkItemDefinition wid2 = defs.get(1);
assertEquals("IncidentPriorityService", wid2.getName());
assertEquals("Incident Priority Service", wid2.getDisplayName());
assertEquals("incidentpriorityicon.png", wid2.getIconDefinition().getUri());
assertEquals(BPMNCategories.CUSTOM_TASKS, wid2.getCategory());
assertEquals(INCIDENT_WID_EXTRACTED_RETURN_PARAMETERS, wid2.getResults());
assertEquals(INCIDENT_WID_EXTRACTED_PARAMETERS, wid2.getParameters());
WorkItemDefinition wid3 = defs.get(2);
assertEquals("Rest", wid3.getName());
assertEquals("REST", wid3.getDisplayName());
assertEquals("defaultservicenodeicon.png", wid3.getIconDefinition().getUri());
assertEquals(REST_WID_RETURN_EXTRACTED_PARAMETERS, wid3.getResults());
assertEquals(REST_WID_EXTRACTED_PARAMETERS, wid3.getParameters());
WorkItemDefinition wid4 = defs.get(3);
assertEquals("Milestone", wid4.getName());
assertEquals("Milestone", wid4.getDisplayName());
assertEquals(ICON_64, wid4.getIconDefinition().getUri());
assertEquals(ICON_64, wid4.getIconDefinition().getIconData());
assertEquals("|Condition:String|", wid4.getParameters());
assertEquals("Milestone", wid4.getCategory());
}
Aggregations