Search in sources :

Example 1 with WorkItemDefinitionRegistry

use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry in project kie-wb-common by kiegroup.

the class WorkItemDefinitionClientRegistryTest method testRegistryProducer.

@Test
public void testRegistryProducer() {
    WorkItemDefinitionRegistry registry = tested.getRegistry();
    assertEquals(this.registry, registry);
}
Also used : WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) Test(org.junit.Test)

Example 2 with WorkItemDefinitionRegistry

use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry in project kie-wb-common by kiegroup.

the class BPMNPaletteDefinitionBuilderTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    when(definitionUtils.getDefinitionManager()).thenReturn(definitionManager);
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.registry()).thenReturn(adapterRegistry);
    when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(widAdapter);
    when(widAdapter.getId(eq(customTask))).thenReturn(DefinitionId.build(WID_NAME));
    when(widAdapter.getCategory(eq(customTask))).thenReturn(WID_CAT);
    when(widAdapter.getTitle(eq(customTask))).thenReturn(WID_DISPLAY_NAME);
    when(widAdapter.getDescription(eq(customTask))).thenReturn(WID_DESC);
    ExpandedPaletteDefinitionBuilder paletteDefinitionBuilder = spy(new ExpandedPaletteDefinitionBuilder(definitionUtils, profileManager, definitionsRegistry, translationService));
    doAnswer(invocationOnMock -> {
        Consumer<DefaultPaletteDefinition> definitionConsumer = (Consumer<DefaultPaletteDefinition>) invocationOnMock.getArguments()[1];
        definitionConsumer.accept(PALETTE_DEFINITION);
        return null;
    }).when(paletteDefinitionBuilder).build(eq(canvasHandler), any(Consumer.class));
    Function<WorkItemDefinition, CustomTask> serviceTaskBuilder = wid -> WID.equals(wid) ? customTask : null;
    tested = new BPMNPaletteDefinitionBuilder(definitionManager, paletteDefinitionBuilder, translationService, () -> workItemDefinitionRegistry, serviceTaskBuilder, definitionUtils, new BPMNCategoryDefinitionProvider());
    tested.init();
}
Also used : GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) DefaultPaletteDefinition(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinition) DefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionId) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) DirectionalAssociation(org.kie.workbench.common.stunner.bpmn.definition.DirectionalAssociation) DefinitionsCacheRegistry(org.kie.workbench.common.stunner.core.registry.impl.DefinitionsCacheRegistry) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) RunWith(org.junit.runner.RunWith) IconDefinition(org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) DomainProfileManager(org.kie.workbench.common.stunner.core.profile.DomainProfileManager) Mockito.spy(org.mockito.Mockito.spy) Function(java.util.function.Function) ArrayList(java.util.ArrayList) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) DefinitionAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionAdapter) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Lane(org.kie.workbench.common.stunner.bpmn.definition.Lane) TextAnnotation(org.kie.workbench.common.stunner.bpmn.definition.TextAnnotation) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) NonDirectionalAssociation(org.kie.workbench.common.stunner.bpmn.definition.NonDirectionalAssociation) AdapterManager(org.kie.workbench.common.stunner.core.definition.adapter.AdapterManager) DefaultPaletteDefinitionProviders.getId(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionProviders.getId) Before(org.junit.Before) ExpandedPaletteDefinitionBuilder(org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder) StunnerTranslationService(org.kie.workbench.common.stunner.core.i18n.StunnerTranslationService) EndSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Mockito.times(org.mockito.Mockito.times) AdapterRegistry(org.kie.workbench.common.stunner.core.registry.definition.AdapterRegistry) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) Assert.assertFalse(org.junit.Assert.assertFalse) WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Consumer(java.util.function.Consumer) DefaultPaletteDefinition(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinition) ExpandedPaletteDefinitionBuilder(org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) Before(org.junit.Before)

Example 3 with WorkItemDefinitionRegistry

use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry 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)

Aggregations

WorkItemDefinitionRegistry (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry)3 Before (org.junit.Before)2 Test (org.junit.Test)2 WorkItemDefinition (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition)2 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 RunWith (org.junit.runner.RunWith)1 BPMNDefinitionSet (org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet)1 BPMNTestDefinitionFactory (org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory)1 BPMNDirectDiagramMarshaller (org.kie.workbench.common.stunner.bpmn.backend.BPMNDirectDiagramMarshaller)1 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)1 DirectionalAssociation (org.kie.workbench.common.stunner.bpmn.definition.DirectionalAssociation)1 EndSignalEvent (org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent)1 Lane (org.kie.workbench.common.stunner.bpmn.definition.Lane)1