use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class ObserverBuilderControlTest method testUpdateDMNDiagramIdFromSelectedDMNDiagram.
@Test
public void testUpdateDMNDiagramIdFromSelectedDMNDiagram() {
final DRGElement newDefinition = mock(DRGElement.class);
final Element element = mock(Element.class);
final View elementContent = mock(View.class);
final Object definition = mock(Object.class);
final String selectedDiagramId = "selected diagram id";
final DMNDiagramElement selectedDiagram = mock(DMNDiagramElement.class);
final Id id = mock(Id.class);
when(id.getValue()).thenReturn(selectedDiagramId);
when(selectedDiagram.getId()).thenReturn(id);
when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(selectedDiagram));
when(elementContent.getDefinition()).thenReturn(newDefinition);
when(element.getContent()).thenReturn(elementContent);
observerBuilderControl.updateElementFromDefinition(element, definition);
verify(newDefinition).setDiagramId(selectedDiagramId);
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DRDContextMenuServiceTest method testAddToNewDRD.
@Test
public void testAddToNewDRD() {
final Collection<Node<? extends Definition<?>, Edge>> nodes = mock(Collection.class);
final Definitions definitions = mock(Definitions.class);
final Diagram drgDiagram = mock(Diagram.class);
final List<DMNDiagramElement> diagramElements = mock(List.class);
when(dmnDiagramsSession.getDRGDiagram()).thenReturn(drgDiagram);
when(dmnDiagramUtils.getDefinitions(drgDiagram)).thenReturn(definitions);
when(definitions.getDiagramElements()).thenReturn(diagramElements);
drdContextMenuService.addToNewDRD(nodes);
verify(diagramElements, times(1)).add(Mockito.<DMNDiagramElement>any());
verify(dmnDiagramsSession, times(1)).add(Mockito.<DMNDiagramElement>any(), Mockito.<Diagram>any());
verify(selectedEvent, times(1)).fire(Mockito.<DMNDiagramSelected>any());
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DRDContextMenuServiceTest method mockDmnDiagramTuple.
private DMNDiagramTuple mockDmnDiagramTuple() {
final DMNDiagramTuple dmnDiagramTuple = mock(DMNDiagramTuple.class);
final Diagram diagram = mock(Diagram.class);
final DMNDiagramElement dmnDiagram = mock(DMNDiagramElement.class);
final Id diagramId = new Id("DIAGRAM_ID");
when(dmnDiagramTuple.getStunnerDiagram()).thenReturn(diagram);
when(dmnDiagramTuple.getDMNDiagram()).thenReturn(dmnDiagram);
when(dmnDiagram.getId()).thenReturn(diagramId);
return dmnDiagramTuple;
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DRDContextMenuService method addToNewDRD.
public void addToNewDRD(final Collection<Node<? extends Definition<?>, Edge>> selectedNodes) {
final DMNDiagramElement dmnElement = makeDmnDiagramElement();
final Diagram stunnerElement = buildStunnerElement(dmnElement);
selectedNodes.forEach(addNodesToDRD(dmnElement, stunnerElement));
addDmnDiagramElementToDRG(dmnElement);
dmnDiagramsSession.add(dmnElement, stunnerElement);
selectedEvent.fire(new DMNDiagramSelected(dmnElement));
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DRDContextMenuTest method testContextMenuHandler.
@Test
public void testContextMenuHandler() {
final DMNDiagramTuple diagramTuple1 = new DMNDiagramTuple(mock(Diagram.class), new DMNDiagramElement());
final DMNDiagramTuple diagramTuple2 = new DMNDiagramTuple(mock(Diagram.class), new DMNDiagramElement());
final List<DMNDiagramTuple> diagrams = asList(diagramTuple1, diagramTuple2);
final DMNDiagramElement diagramElement = mock(DMNDiagramElement.class);
when(translationService.getValue(Mockito.<String>any())).thenReturn(StringUtils.EMPTY);
when(drdContextMenuService.getDiagrams()).thenReturn(diagrams);
when(dmnDiagramsSession.getDRGDiagramElement()).thenReturn(diagramElement);
when(dmnDiagramsSession.getCurrentDMNDiagramElement()).thenReturn(Optional.of(diagramElement));
drdContextMenu.setDRDContextMenuHandler(contextMenu, Collections.singletonList(node));
verify(contextMenu).setHeaderMenu(any(), any());
verify(contextMenu, times(4)).addTextMenuItem(any(), anyBoolean(), any());
}
Aggregations