use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition 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);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionTest method testDefinitionContainsDRGElement.
@Test
public void testDefinitionContainsDRGElement() {
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);
assertTrue(dmnDiagramsSession.definitionContainsDRGElement(nodeWithContentDefinition));
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DecisionNavigatorBaseItemFactoryTest method testMakeItem.
@Test
@SuppressWarnings("unchecked")
public void testMakeItem() {
final String itemUUID = "itemUUID";
final String childUUID = "childUUID";
final String graphUUID = "graphUUID";
final String label = "label";
final Command onClick = mock(Command.class);
final Node<Definition, Edge> diagramNode = mock(Node.class);
final Definition diagramDefinition = mock(Definition.class);
final DMNDiagram diagram = mock(DMNDiagram.class);
final DecisionNavigatorItem child = new DecisionNavigatorItemBuilder().withUUID(childUUID).build();
final List<DecisionNavigatorItem> nestedItems = singletonList(child);
when(node.getUUID()).thenReturn(itemUUID);
doReturn(label).when(factory).getLabel(node);
doReturn(onClick).when(factory).makeOnClickCommand(node);
doReturn(nestedItems).when(factory).makeNestedItems(node);
when(graph.nodes()).thenReturn(Collections.singletonList(diagramNode));
when(diagramNode.getContent()).thenReturn(diagramDefinition);
when(diagramDefinition.getDefinition()).thenReturn(diagram);
when(diagramNode.getUUID()).thenReturn(graphUUID);
final DecisionNavigatorItem item = factory.makeItem(node, ITEM);
assertEquals(itemUUID, item.getUUID());
assertEquals(label, item.getLabel());
assertTrue(item.getOnClick().isPresent());
assertEquals(onClick, item.getOnClick().get());
assertEquals(asTreeSet(child), item.getChildren());
assertEquals(itemUUID, child.getParentUUID());
}
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);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNFlowActionsToolboxFactory method getActions.
@Override
@SuppressWarnings("unchecked")
public Collection<ToolboxAction<AbstractCanvasHandler>> getActions(final AbstractCanvasHandler canvasHandler, final Element<?> element) {
final Set<ToolboxAction<AbstractCanvasHandler>> actions = new LinkedHashSet<>();
final Node<Definition<Object>, Edge> node = (Node<Definition<Object>, Edge>) element;
final Diagram diagram = canvasHandler.getDiagram();
final String defSetId = diagram.getMetadata().getDefinitionSetId();
final CommonDomainLookups lookup = toolboxDomainLookups.get(defSetId);
// Look for the allowed connectors present in the Definition Set.
final Set<String> allowedConnectorIds = lookup.lookupTargetConnectors(node);
for (final String allowedConnectorId : allowedConnectorIds) {
// Append a new action for each connector.
actions.add(createConnectorActions.get().setEdgeId(allowedConnectorId));
// Append a new action for each candidate target node (as from the current connector).
final Set<String> defIds = lookup.lookupTargetNodes(diagram.getGraph(), node, allowedConnectorId);
defIds.forEach(definitionId -> actions.add(createNodeActions.get().setEdgeId(allowedConnectorId).setNodeId(definitionId)));
}
return actions;
}
Aggregations