Search in sources :

Example 1 with ExpandedPaletteDefinitionBuilder

use of org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder in project kie-wb-common by kiegroup.

the class CaseManagementPaletteDefinitionBuilderTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    paletteDefinitionBuilder = new ExpandedPaletteDefinitionBuilder(definitionUtils, clientFactoryServices, translationService);
    tested = new CaseManagementPaletteDefinitionBuilder(paletteDefinitionBuilder, definitionManager);
}
Also used : ExpandedPaletteDefinitionBuilder(org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder) Before(org.junit.Before)

Example 2 with ExpandedPaletteDefinitionBuilder

use of org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder 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(serviceTask))).thenReturn(WID_NAME);
    when(widAdapter.getCategory(eq(serviceTask))).thenReturn(WID_CAT);
    when(widAdapter.getTitle(eq(serviceTask))).thenReturn(WID_DISPLAY_NAME);
    when(widAdapter.getDescription(eq(serviceTask))).thenReturn(WID_DESC);
    ExpandedPaletteDefinitionBuilder paletteDefinitionBuilder = spy(new ExpandedPaletteDefinitionBuilder(definitionUtils, clientFactoryServices, 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, ServiceTask> serviceTaskBuilder = wid -> WID.equals(wid) ? serviceTask : null;
    tested = new BPMNPaletteDefinitionBuilder(definitionManager, paletteDefinitionBuilder, translationService, () -> workItemDefinitionRegistry, serviceTaskBuilder);
    tested.init();
}
Also used : GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) DefaultPaletteDefinition(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinition) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) Mockito.spy(org.mockito.Mockito.spy) Function(java.util.function.Function) ArrayList(java.util.ArrayList) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) DefinitionAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionAdapter) Matchers.eq(org.mockito.Matchers.eq) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Lane(org.kie.workbench.common.stunner.bpmn.definition.Lane) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) 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) ServiceTask(org.kie.workbench.common.stunner.bpmn.workitem.ServiceTask) 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) ClientFactoryService(org.kie.workbench.common.stunner.core.client.service.ClientFactoryService) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) Matchers.any(org.mockito.Matchers.any) 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) ServiceTask(org.kie.workbench.common.stunner.bpmn.workitem.ServiceTask) 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) Before(org.junit.Before)

Example 3 with ExpandedPaletteDefinitionBuilder

use of org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder in project kie-wb-common by kiegroup.

the class BPMNPaletteDefinitionBuilderTest method testFilteredItems.

@Test
public void testFilteredItems() {
    ExpandedPaletteDefinitionBuilder delegate = tested.getPaletteDefinitionBuilder();
    assertTrue(delegate.getItemFilter().test(getId(UserTask.class)));
    assertTrue(delegate.getItemFilter().test(getId(Lane.class)));
    assertTrue(delegate.getItemFilter().test(getId(StartNoneEvent.class)));
    assertTrue(delegate.getItemFilter().test(getId(EndSignalEvent.class)));
    assertFalse(delegate.getItemFilter().test(getId(BPMNDiagramImpl.class)));
    assertFalse(delegate.getItemFilter().test(getId(SequenceFlow.class)));
    assertFalse(delegate.getItemFilter().test(getId(NoneTask.class)));
}
Also used : ExpandedPaletteDefinitionBuilder(org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder) Test(org.junit.Test)

Aggregations

ExpandedPaletteDefinitionBuilder (org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder)3 Before (org.junit.Before)2 Test (org.junit.Test)2 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 ArrayList (java.util.ArrayList)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 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)1 EndSignalEvent (org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent)1 Lane (org.kie.workbench.common.stunner.bpmn.definition.Lane)1 NoneTask (org.kie.workbench.common.stunner.bpmn.definition.NoneTask)1 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)1 StartNoneEvent (org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent)1 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)1 ServiceTask (org.kie.workbench.common.stunner.bpmn.workitem.ServiceTask)1 WorkItemDefinition (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition)1