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);
}
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;
}
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);
}
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());
}
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;
}
Aggregations