use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DeleteNodeConfirmationImplTest method createNodeMockWithContentId.
private Node createNodeMockWithContentId(final String contentId) {
final Node element = mock(Node.class);
final Definition definition = mock(Definition.class);
final HasContentDefinitionId contentDefinitionId = mock(HasContentDefinitionId.class);
when(element.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(contentDefinitionId);
when(contentDefinitionId.getContentDefinitionId()).thenReturn(contentId);
return element;
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition 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);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition 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;
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method testSelectHeaderCellWithDomainObjectInStunnerGraph.
@Test
public void testSelectHeaderCellWithDomainObjectInStunnerGraph() {
grid.getModel().appendColumn(new RowNumberColumn());
grid.getModel().appendColumn(new RowNumberColumn());
// Mock graph to contain decision
final Definition definition = mock(Definition.class);
when(node.getUUID()).thenReturn(NODE_UUID);
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(decision);
// Mock grid to dispatch header selection as a DomainObject
doAnswer(i -> {
grid.fireDomainObjectSelectionEvent(decision);
return null;
}).when(grid).doAfterHeaderSelectionChange(anyInt(), anyInt());
grid.selectHeaderCell(0, 1, false, false);
assertHeaderSelection();
verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesEventCaptor.capture());
final RefreshFormPropertiesEvent refreshFormPropertiesEvent = refreshFormPropertiesEventCaptor.getValue();
assertThat(refreshFormPropertiesEvent.getUuid()).isEqualTo(NODE_UUID);
assertThat(refreshFormPropertiesEvent.getSession()).isEqualTo(session);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNMarshallerTest method testWithIncludedModelsWhenNodeAlreadyHasImports.
@Test
public void testWithIncludedModelsWhenNodeAlreadyHasImports() {
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 DMNDiagram nodeDiagram = mock(DMNDiagram.class);
final Definitions nodeDiagramDefinitions = mock(Definitions.class);
final List<Import> nodeDiagramImports = new ArrayList<>(asList(import1, import2));
when(node.getContent()).thenReturn(nodeDefinition);
when(nodeDefinition.getDefinition()).thenReturn(drgElement);
when(definitionsStunnerPojo.getImport()).thenReturn(diagramImports);
when(drgElement.getParent()).thenReturn(nodeDiagram);
when(nodeDiagram.getDefinitions()).thenReturn(nodeDiagramDefinitions);
when(nodeDiagramDefinitions.getImport()).thenReturn(nodeDiagramImports);
dmnMarshaller.withIncludedModels(node, definitionsStunnerPojo);
assertEquals(2, nodeDiagramImports.size());
assertTrue(nodeDiagramImports.contains(import1));
assertTrue(nodeDiagramImports.contains(import2));
}
Aggregations