use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent in project kie-wb-common by kiegroup.
the class ExpressionEditorTest method testOnCanvasElementUpdated.
@Test
public void testOnCanvasElementUpdated() {
final CanvasElementUpdatedEvent event = new CanvasElementUpdatedEvent(canvasHandler, node);
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(decision);
setupExpression(decision, decision, toolbarStateHandler, false);
testedEditor.handleCanvasElementUpdated(event);
verify(view).setExpressionNameText(optionalHasNameCaptor.capture());
verify(view).refresh();
final Optional<HasName> optionalHasName = optionalHasNameCaptor.getValue();
assertTrue(optionalHasName.isPresent());
assertEquals(decision, optionalHasName.get());
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent in project kie-wb-common by kiegroup.
the class ExpressionEditorTest method testOnCanvasElementUpdatedBusinessKnowledgeModel.
@Test
public void testOnCanvasElementUpdatedBusinessKnowledgeModel() {
final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel();
final CanvasElementUpdatedEvent event = new CanvasElementUpdatedEvent(canvasHandler, node);
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(bkm);
setupExpression(bkm.asHasExpression(), bkm, toolbarStateHandler, false);
testedEditor.handleCanvasElementUpdated(event);
verify(view).setExpressionNameText(optionalHasNameCaptor.capture());
verify(view).refresh();
final Optional<HasName> optionalHasName = optionalHasNameCaptor.getValue();
assertTrue(optionalHasName.isPresent());
assertEquals(bkm, optionalHasName.get());
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent in project kie-wb-common by kiegroup.
the class NodeTextSetterTest method testFireCanvasElementUpdated.
@Test
public void testFireCanvasElementUpdated() {
final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
final Node node = mock(Node.class);
nodeTextSetter.fireCanvasElementUpdated(canvasHandler, node);
verify(canvasElementUpdatedEvent).fire(canvasElementUpdatedEventArgumentCaptor.capture());
final CanvasElementUpdatedEvent arg = canvasElementUpdatedEventArgumentCaptor.getValue();
assertEquals(canvasHandler, arg.getCanvasHandler());
assertEquals(node, arg.getElement());
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent in project kie-wb-common by kiegroup.
the class ExpressionEditorControlImplTest method testBindDomainObjectListenerWithNoNodeMatch.
@Test
public void testBindDomainObjectListenerWithNoNodeMatch() {
when(graph.nodes()).thenReturn(Collections.emptyList());
control.bind(session);
verify(canvasHandler).addDomainObjectListener(domainObjectListenerCaptor.capture());
final CanvasDomainObjectListener domainObjectListener = domainObjectListenerCaptor.getValue();
domainObjectListener.update(domainObject);
verify(canvasElementUpdatedEvent, never()).fire(any(CanvasElementUpdatedEvent.class));
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.registration.CanvasElementUpdatedEvent in project kie-wb-common by kiegroup.
the class ExpressionEditorControlImplTest method testBindDomainObjectListenerWithNodeMatch.
@Test
public void testBindDomainObjectListenerWithNodeMatch() {
final Definition definition = mock(Definition.class);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(domainObject);
when(domainObject.getDomainObjectUUID()).thenReturn("uuid");
control.bind(session);
verify(canvasHandler).addDomainObjectListener(domainObjectListenerCaptor.capture());
final CanvasDomainObjectListener domainObjectListener = domainObjectListenerCaptor.getValue();
domainObjectListener.update(domainObject);
verify(canvasElementUpdatedEvent).fire(canvasElementUpdatedEventCaptor.capture());
final CanvasElementUpdatedEvent canvasElementUpdatedEvent = canvasElementUpdatedEventCaptor.getValue();
assertThat(canvasElementUpdatedEvent.getCanvasHandler()).isEqualTo(canvasHandler);
assertThat(canvasElementUpdatedEvent.getElement()).isEqualTo(node);
}
Aggregations