use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionTest method testSetCurrentDMNDiagramElement.
@Test
public void testSetCurrentDMNDiagramElement() {
final DMNDiagramElement diagramElement = new DMNDiagramElement(new Id(), new Name("DRG"));
final Diagram stunnerDiagram = mock(Diagram.class);
final DMNDiagramSelected selectedDiagram = new DMNDiagramSelected(diagramElement);
dmnDiagramsSession.add(diagramElement, stunnerDiagram);
dmnDiagramsSession.onDMNDiagramSelected(selectedDiagram);
verify(dmnDiagramsSessionState).setCurrentDMNDiagramElement(diagramElement);
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionTest method testOnDMNDiagramSelected_WhenDopesNotBelongsToCurrentSessionState.
@Test
public void testOnDMNDiagramSelected_WhenDopesNotBelongsToCurrentSessionState() {
final DMNDiagramElement selectedDiagramElement = mock(DMNDiagramElement.class);
final DMNDiagramSelected dmnDiagramSelected = new DMNDiagramSelected(selectedDiagramElement);
doNothing().when(dmnDiagramsSession).storeCurrentRegistryHistory();
doReturn(false).when(dmnDiagramsSession).belongsToCurrentSessionState(selectedDiagramElement);
dmnDiagramsSession.onDMNDiagramSelected(dmnDiagramSelected);
verify(dmnDiagramsSessionState, never()).setCurrentDMNDiagramElement(selectedDiagramElement);
verify(dmnDiagramsSession).storeCurrentRegistryHistory();
}
use of org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement in project kie-wb-common by kiegroup.
the class DecisionNavigatorItemFactoryTest method testGetOnUpdate.
@Test
public void testGetOnUpdate() {
final DMNDiagramElement dmnDiagramElement = mock(DMNDiagramElement.class);
final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
final Name dmnDiagramElementName = new Name();
final String newDiagramName = "New diagram name";
when(item.getLabel()).thenReturn(newDiagramName);
when(dmnDiagramElement.getName()).thenReturn(dmnDiagramElementName);
factory.getOnUpdate(dmnDiagramElement).accept(item);
verify(selectedEvent).fire(diagramSelectedArgumentCaptor.capture());
final DMNDiagramElement actualDiagram = diagramSelectedArgumentCaptor.getValue().getDiagramElement();
assertEquals(dmnDiagramElement, actualDiagram);
assertEquals(newDiagramName, actualDiagram.getName().getValue());
}
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 DMNDiagramsSessionTest method testIsGlobalGraphWhenItReturnsFalse.
@Test
public void testIsGlobalGraphWhenItReturnsFalse() {
final DMNDiagramElement diagramElement = new DMNDiagramElement(new Id(), new Name("None"));
final Diagram stunnerDiagram = mock(Diagram.class);
dmnDiagramsSession.add(diagramElement, stunnerDiagram);
dmnDiagramsSession.onDMNDiagramSelected(new DMNDiagramSelected(diagramElement));
assertFalse(dmnDiagramsSession.isGlobalGraphSelected());
}
Aggregations