Search in sources :

Example 26 with WorkItemDefinition

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);
}
Also used : WorkItemDefinitionLookupService(org.kie.workbench.common.stunner.bpmn.workitem.service.WorkItemDefinitionLookupService) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) BPMNTestDefinitionFactory(org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory) BPMNDirectDiagramMarshaller(org.kie.workbench.common.stunner.bpmn.backend.BPMNDirectDiagramMarshaller) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Collection(java.util.Collection) WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) Before(org.junit.Before)

Example 27 with WorkItemDefinition

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());
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Test(org.junit.Test)

Example 28 with WorkItemDefinition

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());
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) DirectoryStream(org.uberfire.backend.vfs.DirectoryStream) Test(org.junit.Test) WorkItemDefinitionParserTest(org.kie.workbench.common.stunner.bpmn.backend.workitem.WorkItemDefinitionParserTest)

Example 29 with WorkItemDefinition

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));
}
Also used : Path(org.uberfire.backend.vfs.Path) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) DirectoryStream(org.uberfire.backend.vfs.DirectoryStream) Test(org.junit.Test) WorkItemDefinitionParserTest(org.kie.workbench.common.stunner.bpmn.backend.workitem.WorkItemDefinitionParserTest)

Example 30 with WorkItemDefinition

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());
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition)

Aggregations

WorkItemDefinition (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition)33 Test (org.junit.Test)18 IconDefinition (org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition)5 Collection (java.util.Collection)4 Dependencies (org.guvnor.common.services.project.model.Dependencies)4 WorkItemDefinitionRegistry (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry)4 Map (java.util.Map)3 Consumer (java.util.function.Consumer)3 Function (java.util.function.Function)3 Inject (javax.inject.Inject)3 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)3 Lane (org.kie.workbench.common.stunner.bpmn.definition.Lane)3 NoneTask (org.kie.workbench.common.stunner.bpmn.definition.NoneTask)3 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)3 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2