use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DecisionComponentsTest method testLoadModelComponents.
@Test
public void testLoadModelComponents() {
final String dmnModelName = "ModelName";
final DRGElement drgElement1 = mock(DRGElement.class);
final DRGElement drgElement2 = mock(DRGElement.class);
final DecisionComponent decisionComponent1 = mock(DecisionComponent.class);
final DecisionComponent decisionComponent2 = mock(DecisionComponent.class);
final List<DecisionComponent> decisionComponentsList = new ArrayList<>();
final Definitions definitions = mock(Definitions.class);
when(definitions.getName()).thenReturn(new Name(dmnModelName));
when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
when(dmnDiagramsSession.getModelDRGElements()).thenReturn(Arrays.asList(drgElement1, drgElement2));
when(drgElement1.getName()).thenReturn(new Name("Decision-1"));
when(drgElement2.getName()).thenReturn(new Name("Decision-2"));
when(decisionComponent1.getName()).thenReturn("Decision-1");
when(decisionComponent2.getName()).thenReturn("Decision-2");
doReturn(decisionComponent1).when(decisionComponents).makeDecisionComponent(dmnModelName, drgElement1);
doReturn(decisionComponent2).when(decisionComponents).makeDecisionComponent(dmnModelName, drgElement2);
doReturn(decisionComponentsList).when(decisionComponents).getModelDRGElements();
doNothing().when(decisionComponents).refreshView();
decisionComponents.loadModelComponents();
assertTrue(decisionComponentsList.contains(decisionComponent1));
assertTrue(decisionComponentsList.contains(decisionComponent2));
assertEquals(2, decisionComponentsList.size());
verify(decisionComponents).refreshView();
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DecisionComponentsItemViewTest method testMakeDragProxyCallbackImplWhenNodeIsNotDuplicated.
@Test
public void testMakeDragProxyCallbackImplWhenNodeIsNotDuplicated() {
final ShapeFactory factory = mock(ShapeFactory.class);
final DRGElement drgElement1 = mock(DRGElement.class);
final DRGElement drgElement2 = mock(DRGElement.class);
final DRGElement drgElement3 = mock(DRGElement.class);
final ClientSession currentSession = mock(ClientSession.class);
final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
final Graph<?, Node> graph = mock(Graph.class);
final List<Node> nodes = new ArrayList<>();
final int x = 10;
final int y = 20;
final String id1 = "123";
final String id2 = "456";
final String id3 = "789";
nodes.add(createNode(id1));
nodes.add(createNode(id2));
when(graph.nodes()).thenReturn(nodes);
when(drgElement1.getId()).thenReturn(new Id(id1));
when(drgElement2.getId()).thenReturn(new Id(id2));
when(drgElement3.getId()).thenReturn(new Id(id3));
when(sessionManager.getCurrentSession()).thenReturn(currentSession);
when(currentSession.getCanvasHandler()).thenReturn(canvasHandler);
doReturn(graph).when(view).getGraph();
view.makeDragProxyCallbackImpl(drgElement3, factory).onComplete(x, y);
verify(notificationEvent, never()).fire(any());
verify(buildCanvasShapeEvent).fire(buildCanvasShapeEventArgumentCaptor.capture());
final BuildCanvasShapeEvent canvasShapeEvent = buildCanvasShapeEventArgumentCaptor.getValue();
assertEquals(canvasHandler, canvasShapeEvent.getCanvasHandler());
assertEquals(drgElement3, canvasShapeEvent.getDefinition());
assertEquals(factory, canvasShapeEvent.getShapeFactory());
assertEquals(x, canvasShapeEvent.getClientX(), 0.1);
assertEquals(y, canvasShapeEvent.getClientY(), 0.1);
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DecisionComponentsItemTest method testGetDrgElement.
@Test
public void testGetDrgElement() {
final DecisionComponent decisionComponent = mock(DecisionComponent.class);
final DRGElement expectedDrgElement = null;
when(decisionComponent.getDrgElement()).thenReturn(expectedDrgElement);
doReturn(decisionComponent).when(item).getDecisionComponent();
final DRGElement actualDrgElement = item.getDrgElement();
assertEquals(expectedDrgElement, actualDrgElement);
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testSynchronizeFromNode.
@Test
public void testSynchronizeFromNode() {
final Node node = mock(Node.class);
final Optional<Node> optional = Optional.of(node);
final Definition definition = mock(Definition.class);
final DRGElement drgElement = mock(DRGElement.class);
doNothing().when(synchronizer).synchronizeElementsFrom(drgElement);
when(definition.getDefinition()).thenReturn(drgElement);
when(node.getContent()).thenReturn(definition);
synchronizer.synchronizeFromNode(optional);
verify(synchronizer).synchronizeElementsFrom(drgElement);
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testGetDRGElementFromContentDefinition.
@Test
public void testGetDRGElementFromContentDefinition() {
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 DRGElement actual = synchronizer.getDRGElementFromContentDefinition(node);
assertEquals(drgElement, actual);
}
Aggregations