Search in sources :

Example 16 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class DecisionComponentsItemViewTest method testMakeDragProxyCallbackImplWhenNodeIsDuplicatedButIsNotImported.

@Test
public void testMakeDragProxyCallbackImplWhenNodeIsDuplicatedButIsNotImported() {
    final ClientSession currentSession = mock(ClientSession.class);
    final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
    final ShapeFactory factory = mock(ShapeFactory.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final int x = 10;
    final int y = 20;
    final Graph<?, Node> graph = mock(Graph.class);
    final List<Node> nodes = new ArrayList<>();
    final String id1 = "123";
    final String id2 = "123";
    nodes.add(createNode(id1));
    nodes.add(createNode(id2));
    when(graph.nodes()).thenReturn(nodes);
    when(drgElement.getId()).thenReturn(new Id(id1));
    when(sessionManager.getCurrentSession()).thenReturn(currentSession);
    when(currentSession.getCanvasHandler()).thenReturn(canvasHandler);
    doReturn(graph).when(view).getGraph();
    view.setIsImported(false);
    view.makeDragProxyCallbackImpl(drgElement, factory).onComplete(x, y);
    verify(buildCanvasShapeEvent).fire(any());
    verify(notificationEvent, never()).fire(notificationEventArgumentCaptor.capture());
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) DecisionComponentsItemView_DuplicatedNode(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionComponentsItemView_DuplicatedNode) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) DMNShapeFactory(org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 17 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class DecisionComponentsItemViewTest method testDecisionComponentItemMouseDown.

@Test
public void testDecisionComponentItemMouseDown() {
    final MouseDownEvent mouseDownEvent = mock(MouseDownEvent.class);
    final Callback proxy = mock(Callback.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final DMNShapeFactory factory = mock(DMNShapeFactory.class);
    final ShapeGlyphDragHandler.Item item = mock(ShapeGlyphDragHandler.Item.class);
    final Glyph glyph = mock(Glyph.class);
    final int x = 10;
    final int y = 20;
    when(dmnShapeSet.getShapeFactory()).thenReturn(factory);
    when(presenter.getDrgElement()).thenReturn(drgElement);
    when(factory.getGlyph(any())).thenReturn(glyph);
    when(mouseDownEvent.getX()).thenReturn(x);
    when(mouseDownEvent.getY()).thenReturn(y);
    doReturn(proxy).when(view).makeDragProxyCallbackImpl(drgElement, factory);
    doReturn(item).when(view).makeDragHandler(glyph);
    view.decisionComponentItemMouseDown(mouseDownEvent);
    verify(shapeGlyphDragHandler).show(item, x, y, proxy);
}
Also used : Item(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Item) Callback(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback) DMNShapeFactory(org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) ShapeGlyphDragHandler(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler) MouseDownEvent(com.google.gwt.event.dom.client.MouseDownEvent) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 18 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class DMNDiagramsSessionStateTest method testGetModelDRGElements.

@Test
public void testGetModelDRGElements() {
    final DRGElement drgElement1 = mock(DRGElement.class);
    final DRGElement drgElement2 = mock(DRGElement.class);
    final DRGElement drgElement3 = mock(DRGElement.class);
    final DRGElement drgElement4 = mock(DRGElement.class);
    final DRGElement drgElement5 = mock(DRGElement.class);
    final DRGElement drgElement6 = mock(DRGElement.class);
    when(dmnDiagramUtils.getDRGElements(stunnerDiagram1)).thenReturn(asList(drgElement1, drgElement2));
    when(dmnDiagramUtils.getDRGElements(stunnerDiagram2)).thenReturn(asList(drgElement3, drgElement4, drgElement5));
    when(dmnDiagramUtils.getDRGElements(stunnerDiagram3)).thenReturn(singletonList(drgElement6));
    final List<DRGElement> drgElements = sessionState.getModelDRGElements();
    assertTrue(drgElements.contains(drgElement1));
    assertTrue(drgElements.contains(drgElement2));
    assertTrue(drgElements.contains(drgElement3));
    assertTrue(drgElements.contains(drgElement4));
    assertTrue(drgElements.contains(drgElement5));
    assertTrue(drgElements.contains(drgElement6));
}
Also used : DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 19 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class DMNDocumentationFactoryTest method testCreate.

@Test
public void testCreate() {
    final String diagramName = "Diagram name";
    final String diagramDescription = "Diagram description";
    final String image = "<image>";
    final String admin = "admin";
    final String currentDate = "2 January 1992";
    final String namespace = "://namespace";
    final String expectedDroolsLogo = "droolsLogo";
    final String expectedSupportedByRedHatLogo = "supportedByRedHatLogo";
    final List<DRGElement> drgElements = singletonList(mock(DRGElement.class));
    final ItemDefinition uuid = makeItemDefinition("tUUID", "String");
    final ItemDefinition id = makeItemDefinition("id", "tUUID");
    final ItemDefinition name = makeItemDefinition("name", "String");
    final ItemDefinition person = makeItemDefinition("tPerson", null, id, name);
    final List<ItemDefinition> itemDefinitions = asList(uuid, person);
    final UnaryTests unaryTests = new UnaryTests();
    unaryTests.setText(new Text("[1, 2, 3]"));
    id.setAllowedValues(unaryTests);
    id.setIsCollection(true);
    doReturn(image).when(documentationFactory).getDiagramImage();
    doReturn(i18n).when(documentationFactory).getDocumentationI18n();
    doReturn(moment).when(documentationFactory).moment();
    when(definitions.getNamespace()).thenReturn(new Text(namespace));
    when(graphUtils.getDefinitions(diagram)).thenReturn(definitions);
    when(definitions.getName()).thenReturn(new Name(diagramName));
    when(definitions.getDescription()).thenReturn(new Description(diagramDescription));
    when(graphUtils.getDRGElements(diagram)).thenReturn(drgElements);
    when(definitions.getItemDefinition()).thenReturn(itemDefinitions);
    when(sessionInfo.getIdentity()).thenReturn(user);
    when(user.getIdentifier()).thenReturn(admin);
    when(moment.format("D MMMM YYYY")).thenReturn(currentDate);
    final DMNDocumentation documentation = documentationFactory.create(diagram);
    assertEquals(namespace, documentation.getNamespace());
    assertEquals(diagramName, documentation.getDiagramName());
    assertEquals(diagramDescription, documentation.getDiagramDescription());
    assertEquals(image, documentation.getDiagramImage());
    assertEquals(admin, documentation.getCurrentUser());
    assertEquals(currentDate, documentation.getCurrentDate());
    assertEquals(expectedDroolsLogo, documentation.getDroolsLogoURI());
    assertEquals(expectedSupportedByRedHatLogo, documentation.getSupportedByRedHatLogoURI());
    assertEquals(i18n, documentation.getI18n());
    assertNotNull(documentation.getModuleName());
    assertNotNull(documentation.getDataTypes());
    assertTrue(documentation.hasGraphNodes());
    final List<DMNDocumentationDataType> dataTypes = documentation.getDataTypesList();
    assertEquals(4, dataTypes.size());
    assertEquals("", dataTypes.get(0).getConstraint());
    assertEquals("tUUID", dataTypes.get(0).getName());
    assertEquals("String", dataTypes.get(0).getType());
    assertEquals("", dataTypes.get(0).getListLabel());
    assertEquals(0, dataTypes.get(0).getLevel());
    assertTrue(dataTypes.get(0).isTopLevel());
    assertEquals("", dataTypes.get(1).getConstraint());
    assertEquals("tPerson", dataTypes.get(1).getName());
    assertEquals("Structure", dataTypes.get(1).getType());
    assertEquals("", dataTypes.get(1).getListLabel());
    assertEquals(0, dataTypes.get(1).getLevel());
    assertTrue(dataTypes.get(1).isTopLevel());
    assertEquals("Constraints: [1, 2, 3]", dataTypes.get(2).getConstraint());
    assertEquals("id", dataTypes.get(2).getName());
    assertEquals("tUUID", dataTypes.get(2).getType());
    assertEquals("List: Yes", dataTypes.get(2).getListLabel());
    assertEquals(1, dataTypes.get(2).getLevel());
    assertFalse(dataTypes.get(2).isTopLevel());
    assertEquals("", dataTypes.get(3).getConstraint());
    assertEquals("name", dataTypes.get(3).getName());
    assertEquals("String", dataTypes.get(3).getType());
    assertEquals("", dataTypes.get(3).getListLabel());
    assertEquals(1, dataTypes.get(3).getLevel());
    assertFalse(dataTypes.get(3).isTopLevel());
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Test(org.junit.Test)

Example 20 with DRGElement

use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.

the class DMNDiagramsSessionTest method testGetDRGElementFromContentDefinition.

@Test
public void testGetDRGElementFromContentDefinition() {
    final Node nodeWithContentDefinition = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final DRGElement drgElement = mock(DRGElement.class);
    when(nodeWithContentDefinition.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(drgElement);
    final DRGElement actual = dmnDiagramsSession.getDRGElementFromContentDefinition(nodeWithContentDefinition);
    assertEquals(drgElement, actual);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Aggregations

DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)72 Test (org.junit.Test)45 Node (org.kie.workbench.common.stunner.core.graph.Node)27 ArrayList (java.util.ArrayList)25 Edge (org.kie.workbench.common.stunner.core.graph.Edge)17 View (org.kie.workbench.common.stunner.core.graph.content.view.View)17 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)16 List (java.util.List)15 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)15 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)15 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)15 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)14 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)10 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)9 Import (org.kie.workbench.common.dmn.api.definition.model.Import)9 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)8 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)7 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)7 Optional (java.util.Optional)6