Search in sources :

Example 6 with HasContentDefinitionId

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

the class SafeDeleteNodeProcessorTest method testInit.

@Test
public void testInit() {
    final Graph graph = mock(Graph.class);
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    final String definitionId = "definition id";
    final String dmnDiagramId = "dmn diagram id";
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(hasContentDefinitionId);
    when(hasContentDefinitionId.getContentDefinitionId()).thenReturn(definitionId);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(dmnDiagramId);
    this.tested = new SafeDeleteNodeProcessor(new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()), graph, node);
    tested.init();
    final String candidateContentDefinitionId = tested.getCandidateContentDefinitionId();
    final String candidateDmnDiagramId = tested.getCandidateDiagramId();
    assertEquals(definitionId, candidateContentDefinitionId);
    assertEquals(dmnDiagramId, candidateDmnDiagramId);
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) ChildrenTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.content.ChildrenTraverseProcessorImpl) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TreeWalkTraverseProcessorImpl(org.kie.workbench.common.stunner.core.graph.processing.traverse.tree.TreeWalkTraverseProcessorImpl) Test(org.junit.Test)

Example 7 with HasContentDefinitionId

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

the class SafeDeleteNodeProcessorTest method createNode.

private Node createNode(final String contentDefinitionId, final String diagramId) {
    final Node node = mock(Node.class);
    final Definition content = mock(Definition.class);
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    when(hasContentDefinitionId.getContentDefinitionId()).thenReturn(contentDefinitionId);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(diagramId);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(hasContentDefinitionId);
    return node;
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition)

Example 8 with HasContentDefinitionId

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

the class DMNCanvasHandlerTest method testUpdateDiagramIdWhenDiagramIdIsNull.

@Test
public void testUpdateDiagramIdWhenDiagramIdIsNull() {
    final String diagramId = "diagram id";
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    final Element element = getElementForTestUpdateDiagramId(diagramId, null, hasContentDefinitionId);
    canvasHandler.updateDiagramId(element);
    verify(hasContentDefinitionId).setDiagramId(diagramId);
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Element(org.kie.workbench.common.stunner.core.graph.Element) Test(org.junit.Test)

Example 9 with HasContentDefinitionId

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

the class DMNCanvasHandlerTest method testUpdateDiagramIdWhenDiagramIdIsSet.

@Test
public void testUpdateDiagramIdWhenDiagramIdIsSet() {
    final String diagramId = "diagram id";
    final String currentDiagramId = "some set diagram";
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    final Element element = getElementForTestUpdateDiagramId(diagramId, currentDiagramId, hasContentDefinitionId);
    canvasHandler.updateDiagramId(element);
    verify(hasContentDefinitionId, never()).setDiagramId(Mockito.<String>any());
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Element(org.kie.workbench.common.stunner.core.graph.Element) Test(org.junit.Test)

Example 10 with HasContentDefinitionId

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

the class DRDContextMenuService method cloneDefinition.

private HasContentDefinitionId cloneDefinition(final DMNDiagramElement dmnElement, final Object definition) {
    final HasContentDefinitionId originalDefinition = (HasContentDefinitionId) definition;
    final HasContentDefinitionId clonedDefinition = dmnDeepCloneProcess.clone(originalDefinition);
    clonedDefinition.setContentDefinitionId(originalDefinition.getContentDefinitionId());
    clonedDefinition.setDiagramId(dmnElement.getId().getValue());
    if (definition instanceof HasText && clonedDefinition instanceof HasText) {
        HasText hasText = (HasText) definition;
        ((HasText) clonedDefinition).setText(hasText.getText());
    }
    if (definition instanceof HasName && clonedDefinition instanceof HasName) {
        HasName hasName = (HasName) definition;
        ((HasName) clonedDefinition).setName(hasName.getValue());
    }
    return clonedDefinition;
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) HasText(org.kie.workbench.common.dmn.api.definition.HasText) HasName(org.kie.workbench.common.dmn.api.definition.HasName)

Aggregations

HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)18 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)9 Node (org.kie.workbench.common.stunner.core.graph.Node)8 Test (org.junit.Test)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5 Element (org.kie.workbench.common.stunner.core.graph.Element)4 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)3 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 HasName (org.kie.workbench.common.dmn.api.definition.HasName)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1