Search in sources :

Example 51 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class DMNMarshallerTest method testWithIncludedModelsWhenNodeParentIsDefinitions.

@Test
public void testWithIncludedModelsWhenNodeParentIsDefinitions() {
    final DMNMarshaller dmnMarshaller = spy(new DMNMarshaller());
    final Node node = mock(Node.class);
    final Definition nodeDefinition = mock(Definition.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final Definitions definitionsStunnerPojo = mock(Definitions.class);
    final Import import1 = mock(Import.class);
    final Import import2 = mock(Import.class);
    final List<Import> diagramImports = new ArrayList<>(asList(import1, import2));
    final Definitions nodeDiagramDefinitions = mock(Definitions.class);
    final List<Import> nodeDiagramImports = new ArrayList<>();
    when(node.getContent()).thenReturn(nodeDefinition);
    when(nodeDefinition.getDefinition()).thenReturn(drgElement);
    when(definitionsStunnerPojo.getImport()).thenReturn(diagramImports);
    when(drgElement.getParent()).thenReturn(nodeDiagramDefinitions);
    when(nodeDiagramDefinitions.getImport()).thenReturn(nodeDiagramImports);
    dmnMarshaller.withIncludedModels(node, definitionsStunnerPojo);
    assertEquals(2, nodeDiagramImports.size());
    assertTrue(nodeDiagramImports.contains(import1));
    assertTrue(nodeDiagramImports.contains(import2));
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) Node(org.kie.workbench.common.stunner.core.graph.Node) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) JSITDefinitions(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) ArrayList(java.util.ArrayList) JSITDRGElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDRGElement) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 52 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class AbstractCanvasInlineTextEditorControlTest method testAllowOnlyVisualChanges.

@Test
public void testAllowOnlyVisualChanges() {
    final Element element = mock(Element.class);
    final Definition definition = mock(Definition.class);
    final DynamicReadOnly dynamicReadOnly = mock(DynamicReadOnly.class);
    when(element.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(dynamicReadOnly);
    boolean actual = control.allowOnlyVisualChanges(element);
    assertFalse(actual);
    when(dynamicReadOnly.isAllowOnlyVisualChange()).thenReturn(true);
    actual = control.allowOnlyVisualChanges(element);
    assertTrue(actual);
}
Also used : DynamicReadOnly(org.kie.workbench.common.forms.adf.definitions.DynamicReadOnly) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Test(org.junit.Test)

Example 53 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class BaseAppendNodeShortcutTest method testMatchesSelectedElement.

@Test
public void testMatchesSelectedElement() {
    final SoftAssertions softly = new SoftAssertions();
    getNotAcceptableSelectedElements().forEach(element -> softly.assertThat(testedShortcut.matchesSelectedElement(element)).as("It shouldn't react on selected element: " + ((Definition) element.getContent()).getDefinition()).isFalse());
    getAcceptableSelectedElements().forEach(element -> softly.assertThat(testedShortcut.matchesSelectedElement(element)).as("It should react on selected element: " + ((Definition) element.getContent()).getDefinition()).isTrue());
    softly.assertAll();
}
Also used : SoftAssertions(org.assertj.core.api.SoftAssertions) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Test(org.junit.Test)

Example 54 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class DMNElementsSynchronizerTest method testDefinitionContainsDRGElement_WhenDoesNotContains.

@Test
public void testDefinitionContainsDRGElement_WhenDoesNotContains() {
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final Object obj = mock(Object.class);
    when(definition.getDefinition()).thenReturn(obj);
    when(node.getContent()).thenReturn(definition);
    final boolean containsDRGElement = synchronizer.definitionContainsDRGElement(node);
    assertFalse(containsDRGElement);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Test(org.junit.Test)

Example 55 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class FormPropertiesWidgetTest method testIsFiltered.

@Test
public void testIsFiltered() {
    NodeImpl nodeNullContent = mock(NodeImpl.class);
    when(nodeNullContent.getContent()).thenReturn(null);
    assertFalse(FormPropertiesWidget.isFiltered(nodeNullContent));
    Definition content = mock(Definition.class);
    NodeImpl nodeUnfiltered = mock(NodeImpl.class);
    Object unfilteredDefinition = mock(Object.class);
    when(nodeUnfiltered.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(unfilteredDefinition);
    assertFalse(FormPropertiesWidget.isFiltered(nodeUnfiltered));
    NodeImpl nodeFiltered = mock(NodeImpl.class);
    when(nodeFiltered.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(CUSTOM_DEFINITION);
    assertTrue(FormPropertiesWidget.isFiltered(nodeFiltered));
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject) Test(org.junit.Test)

Aggregations

Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)111 Node (org.kie.workbench.common.stunner.core.graph.Node)61 Test (org.junit.Test)46 Element (org.kie.workbench.common.stunner.core.graph.Element)31 Edge (org.kie.workbench.common.stunner.core.graph.Edge)25 Graph (org.kie.workbench.common.stunner.core.graph.Graph)20 ArrayList (java.util.ArrayList)16 Optional (java.util.Optional)14 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)14 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)14 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)14 View (org.kie.workbench.common.stunner.core.graph.content.view.View)12 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)11 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)10 List (java.util.List)9 Before (org.junit.Before)9 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)9 HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)9 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)9 Stream (java.util.stream.Stream)8