use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class UpdateElementPositionCommandTest method testExecuteDockedNode.
@Test
@SuppressWarnings("unchecked")
public void testExecuteDockedNode() {
ArgumentCaptor<Bounds> boundsArgumentCaptor = ArgumentCaptor.forClass(Bounds.class);
this.tested = new UpdateElementPositionCommand(dockedNode, new Point2D(600d, 600d));
final CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
verify((View) dockedNode.getContent(), times(1)).setBounds(boundsArgumentCaptor.capture());
assertEquals(CommandResult.Type.INFO, result.getType());
Bounds bounds = boundsArgumentCaptor.getValue();
assertEquals(bounds.getUpperLeft(), Bound.create(600d, 600d));
assertEquals(bounds.getLowerRight(), Bound.create(650d, 650d));
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class MagnetConnectionTest method testForTargetAtRight.
@Test
@SuppressWarnings("unchecked")
public void testForTargetAtRight() {
Bounds bounds2 = Bounds.create(120d, 30d, 200d, 300d);
when(element2.getContent()).thenReturn(content2);
when(content2.getBounds()).thenReturn(bounds2);
MagnetConnection m1 = MagnetConnection.Builder.forTarget(element, element2);
assertEquals(Point2D.create(90, 90), m1.getLocation());
assertEquals(MagnetConnection.MAGNET_RIGHT, m1.getMagnetIndex().getAsInt());
assertTrue(m1.isAuto());
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class MagnetConnectionTest method testForTargetAtLeft.
@Test
@SuppressWarnings("unchecked")
public void testForTargetAtLeft() {
Bounds bounds2 = Bounds.create(-40d, 10d, 0d, 300d);
when(element2.getContent()).thenReturn(content2);
when(content2.getBounds()).thenReturn(bounds2);
MagnetConnection m1 = MagnetConnection.Builder.forTarget(element, element2);
assertEquals(Point2D.create(0, 90), m1.getLocation());
assertEquals(MagnetConnection.MAGNET_LEFT, m1.getMagnetIndex().getAsInt());
assertTrue(m1.isAuto());
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class SugiyamaLayoutServiceTest method testGetWidth.
@Test
public void testGetWidth() {
final Node n = mock(Node.class);
final HasBounds hasBounds = mock(HasBounds.class);
final Bounds bounds = mock(Bounds.class);
final double width = 17;
final int expected = (int) width;
when(bounds.getWidth()).thenReturn(width);
when(hasBounds.getBounds()).thenReturn(bounds);
when(n.getContent()).thenReturn(hasBounds);
int actual = layoutService.getWidth(n);
assertEquals(expected, actual);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class CloneNodeCommandTest method testCloneNodeContentWithProperties.
@Test
public void testCloneNodeContentWithProperties() {
final View cloneContent = mock(View.class);
final DefinitionManager definitionManager = mock(DefinitionManager.class);
final CloneManager cloneManager = mock(CloneManager.class);
final Object clonedDefinition = mock(Object.class);
cloneNodeCommand.setClone(clone);
when(clone.getContent()).thenReturn(cloneContent);
when(graphCommandExecutionContext.getDefinitionManager()).thenReturn(definitionManager);
when(definitionManager.cloneManager()).thenReturn(cloneManager);
when(cloneManager.clone(candidateContent.getDefinition(), ClonePolicy.ALL)).thenReturn(clonedDefinition);
cloneNodeCommand.cloneNodeContentWithProperties(graphCommandExecutionContext);
verify(cloneContent).setBounds(boundsArgumentCaptor.capture());
verify(cloneContent).setDefinition(clonedDefinition);
final Bounds clonedBounds = boundsArgumentCaptor.getValue();
assertEquals(candidateBounds, clonedBounds);
assertNotSame(candidateBounds, clonedBounds);
}
Aggregations