use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testDefinitionContainsDRGElement.
@Test
public void testDefinitionContainsDRGElement() {
final Node node = mock(Node.class);
final Definition definition = mock(Definition.class);
final DRGElement drgElement = mock(DRGElement.class);
when(definition.getDefinition()).thenReturn(drgElement);
when(node.getContent()).thenReturn(definition);
final boolean containsDRGElement = synchronizer.definitionContainsDRGElement(node);
assertTrue(containsDRGElement);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class ElementFactoryTest method testBuild.
@Test
public void testBuild() {
final String UUID = "UUID";
final String DEFINITION = "Definition String";
Element element = mock(Element.class);
ElementFactory<String, Definition<String>, Element<Definition<String>>> factory = new ElementFactory() {
@Override
public Class<? extends ElementFactory> getFactoryType() {
return null;
}
@Override
public Element build(String uuid, Object definition) {
return element;
}
@Override
public boolean accepts(Object source) {
return false;
}
};
assertEquals(element, factory.build(UUID, DEFINITION, null));
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class NodeConnector method connectEdgeToNodes.
void connectEdgeToNodes(final String connectorTypeId, final JSITDMNElement jsiDMNElement, final JSITDMNElementReference jsiDMNElementReference, final Map<String, List<NodeEntry>> entriesById, final String diagramId, final List<JSIDMNEdge> edges, final boolean isDMNDIPresent, final Node currentNode) {
final String reqInputID = getId(jsiDMNElementReference);
final List<NodeEntry> nodeEntries = entriesById.get(reqInputID);
if (nodeEntries == null || nodeEntries.isEmpty()) {
return;
}
final Optional<JSIDMNEdge> existingEdge = findExistingEdge(jsiDMNElement, edges);
if (!isDMNDIPresent) {
// Generate new a edge and connect it
final NodeEntry nodeEntry = nodeEntries.get(0);
final Node requiredNode = nodeEntry.getNode();
final View<?> view = (View<?>) requiredNode.getContent();
final double viewWidth = view.getBounds().getWidth();
final double viewHeight = view.getBounds().getHeight();
connectWbEdge(connectorTypeId, diagramId, currentNode, requiredNode, newEdge(viewWidth / 2, viewHeight / 2), uuid());
} else if (existingEdge.isPresent()) {
// Connect existing edge
final JSIDMNEdge edge = Js.uncheckedCast(existingEdge.get());
final Optional<Node> requiredNode = getSourceNode(edge, nodeEntries);
final String id = edge.getDmnElementRef().getLocalPart();
final String currentNodeId = ((DRGElement) ((Definition) currentNode.getContent()).getDefinition()).getContentDefinitionId();
// The edge can be connected with another instance of the same Node and not the currentNode
if (isEdgeConnectedWithNode(edge, currentNode, entriesById.get(currentNodeId))) {
connectWbEdge(connectorTypeId, diagramId, currentNode, requiredNode.get(), edge, id);
}
}
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNCommonActionsToolboxFactoryTest method testAddEditWhenIsNotDecisionOrBusinessKnowledgeModelAction.
@Test
public void testAddEditWhenIsNotDecisionOrBusinessKnowledgeModelAction() {
final List<ToolboxAction<AbstractCanvasHandler>> actions = new ArrayList<>();
final Element element = mock(Element.class);
final Node node = mock(Node.class);
final Definition definition = mock(Definition.class);
final Object someObject = mock(Object.class);
when(element.asNode()).thenReturn(node);
when(element.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(someObject);
tested.addEditAction(element, actions);
assertEquals(0, actions.size());
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNDiagramTextPropertyProviderImplTest method checkSupportsDMNDiagram.
@Test
@SuppressWarnings("unchecked")
public void checkSupportsDMNDiagram() {
assertTrue(provider.supports(element));
final Element other = mock(Element.class);
final Definition otherContent = mock(Definition.class);
final TextAnnotation otherDefinition = mock(TextAnnotation.class);
when(other.getContent()).thenReturn(otherContent);
when(otherContent.getDefinition()).thenReturn(otherDefinition);
assertFalse(provider.supports(other));
}
Aggregations