Search in sources :

Example 11 with DMNDiagramElement

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

the class DMNDiagramsSessionTest method testSetCurrentDMNDiagramElement.

@Test
public void testSetCurrentDMNDiagramElement() {
    final DMNDiagramElement diagramElement = new DMNDiagramElement(new Id(), new Name("DRG"));
    final Diagram stunnerDiagram = mock(Diagram.class);
    final DMNDiagramSelected selectedDiagram = new DMNDiagramSelected(diagramElement);
    dmnDiagramsSession.add(diagramElement, stunnerDiagram);
    dmnDiagramsSession.onDMNDiagramSelected(selectedDiagram);
    verify(dmnDiagramsSessionState).setCurrentDMNDiagramElement(diagramElement);
}
Also used : Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 12 with DMNDiagramElement

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

the class DMNDiagramsSessionTest method testOnDMNDiagramSelected_WhenDopesNotBelongsToCurrentSessionState.

@Test
public void testOnDMNDiagramSelected_WhenDopesNotBelongsToCurrentSessionState() {
    final DMNDiagramElement selectedDiagramElement = mock(DMNDiagramElement.class);
    final DMNDiagramSelected dmnDiagramSelected = new DMNDiagramSelected(selectedDiagramElement);
    doNothing().when(dmnDiagramsSession).storeCurrentRegistryHistory();
    doReturn(false).when(dmnDiagramsSession).belongsToCurrentSessionState(selectedDiagramElement);
    dmnDiagramsSession.onDMNDiagramSelected(dmnDiagramSelected);
    verify(dmnDiagramsSessionState, never()).setCurrentDMNDiagramElement(selectedDiagramElement);
    verify(dmnDiagramsSession).storeCurrentRegistryHistory();
}
Also used : DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Test(org.junit.Test)

Example 13 with DMNDiagramElement

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

the class DecisionNavigatorItemFactoryTest method testGetOnUpdate.

@Test
public void testGetOnUpdate() {
    final DMNDiagramElement dmnDiagramElement = mock(DMNDiagramElement.class);
    final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
    final Name dmnDiagramElementName = new Name();
    final String newDiagramName = "New diagram name";
    when(item.getLabel()).thenReturn(newDiagramName);
    when(dmnDiagramElement.getName()).thenReturn(dmnDiagramElementName);
    factory.getOnUpdate(dmnDiagramElement).accept(item);
    verify(selectedEvent).fire(diagramSelectedArgumentCaptor.capture());
    final DMNDiagramElement actualDiagram = diagramSelectedArgumentCaptor.getValue().getDiagramElement();
    assertEquals(dmnDiagramElement, actualDiagram);
    assertEquals(newDiagramName, actualDiagram.getName().getValue());
}
Also used : DecisionNavigatorItem(org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 14 with DMNDiagramElement

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

the class ObserverBuilderControlTest method testUpdateDMNDiagramIdFromSelectedDMNDiagram.

@Test
public void testUpdateDMNDiagramIdFromSelectedDMNDiagram() {
    final DRGElement newDefinition = mock(DRGElement.class);
    final Element element = mock(Element.class);
    final View elementContent = mock(View.class);
    final Object definition = mock(Object.class);
    final String selectedDiagramId = "selected diagram id";
    final DMNDiagramElement selectedDiagram = mock(DMNDiagramElement.class);
    final Id id = mock(Id.class);
    when(id.getValue()).thenReturn(selectedDiagramId);
    when(selectedDiagram.getId()).thenReturn(id);
    when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(selectedDiagram));
    when(elementContent.getDefinition()).thenReturn(newDefinition);
    when(element.getContent()).thenReturn(elementContent);
    observerBuilderControl.updateElementFromDefinition(element, definition);
    verify(newDefinition).setDiagramId(selectedDiagramId);
}
Also used : DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) Element(org.kie.workbench.common.stunner.core.graph.Element) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) ArgumentMatchers.anyObject(org.mockito.ArgumentMatchers.anyObject) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 15 with DMNDiagramElement

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

the class DMNDiagramsSessionTest method testIsGlobalGraphWhenItReturnsFalse.

@Test
public void testIsGlobalGraphWhenItReturnsFalse() {
    final DMNDiagramElement diagramElement = new DMNDiagramElement(new Id(), new Name("None"));
    final Diagram stunnerDiagram = mock(Diagram.class);
    dmnDiagramsSession.add(diagramElement, stunnerDiagram);
    dmnDiagramsSession.onDMNDiagramSelected(new DMNDiagramSelected(diagramElement));
    assertFalse(dmnDiagramsSession.isGlobalGraphSelected());
}
Also used : Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Aggregations

DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)35 Test (org.junit.Test)23 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)21 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)13 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)10 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)8 Node (org.kie.workbench.common.stunner.core.graph.Node)7 View (org.kie.workbench.common.stunner.core.graph.content.view.View)6 DMNDiagramTuple (org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple)5 Graph (org.kie.workbench.common.stunner.core.graph.Graph)5 DecisionNavigatorItem (org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem)4 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)3 HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)3 JSONString (com.google.gwt.json.client.JSONString)2 QName (javax.xml.namespace.QName)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)2