Package org.jmock

Examples of org.jmock.Mock.expects()


    Mock mockNode2 = mock(Node.class);
    double node2X2 = 55.0, node2Y2 = 67.0;
    mockNode2.expects(once()).method("setParent").with(eq(diagram));
    mockNode2.expects(atLeastOnce()).method("getAbsoluteX2").
      will(returnValue(node2X2));
    mockNode2.expects(atLeastOnce()).method("getAbsoluteY2").
      will(returnValue(node2Y2));
    diagram.addChild((DiagramElement) mockNode2.proxy());
    assertTrue(diagram.getSize().getWidth() >= node2X2);
    assertTrue(diagram.getSize().getHeight() >= node2Y2);
    diagram.removeChild((DiagramElement) mockNode2.proxy());
View Full Code Here


   * and nodes.
   */
  public void testOverriddenGetChildren() {
    Connection conn = new SimpleConnection();
    Mock mockNode = mock(Node.class);
    mockNode.expects(atLeastOnce()).method("getAbsoluteX2")
      .will(returnValue(2.0));
    mockNode.expects(atLeastOnce()).method("getAbsoluteY2")
      .will(returnValue(2.0));
    mockNode.expects(once()).method("setParent").with(eq(diagram));
    diagram.addChild((DiagramElement) mockNode.proxy());
View Full Code Here

  public void testOverriddenGetChildren() {
    Connection conn = new SimpleConnection();
    Mock mockNode = mock(Node.class);
    mockNode.expects(atLeastOnce()).method("getAbsoluteX2")
      .will(returnValue(2.0));
    mockNode.expects(atLeastOnce()).method("getAbsoluteY2")
      .will(returnValue(2.0));
    mockNode.expects(once()).method("setParent").with(eq(diagram));
    diagram.addChild((DiagramElement) mockNode.proxy());
    diagram.addChild(conn);
    assertTrue(diagram.getChildren().contains(mockNode.proxy()));
View Full Code Here

    Mock mockNode = mock(Node.class);
    mockNode.expects(atLeastOnce()).method("getAbsoluteX2")
      .will(returnValue(2.0));
    mockNode.expects(atLeastOnce()).method("getAbsoluteY2")
      .will(returnValue(2.0));
    mockNode.expects(once()).method("setParent").with(eq(diagram));
    diagram.addChild((DiagramElement) mockNode.proxy());
    diagram.addChild(conn);
    assertTrue(diagram.getChildren().contains(mockNode.proxy()));
    assertTrue(diagram.getChildren().contains(conn));
  }
View Full Code Here

    assertEquals("oldlabel", cloned.getLabelText());
    note.setLabelText("mylabel");
    assertFalse(cloned.getLabelText() == note.getLabelText());
   
    // now test the label
    mockParent1.expects(atLeastOnce()).method("getAbsoluteX1")
      .will(returnValue(0.0));
    mockParent1.expects(atLeastOnce()).method("getAbsoluteY1")
      .will(returnValue(0.0));
    assertNotNull(cloned.getLabelAt(20, 20));
    assertNull(cloned.getLabelAt(-1.0, -2.0));
View Full Code Here

    assertFalse(cloned.getLabelText() == note.getLabelText());
   
    // now test the label
    mockParent1.expects(atLeastOnce()).method("getAbsoluteX1")
      .will(returnValue(0.0));
    mockParent1.expects(atLeastOnce()).method("getAbsoluteY1")
      .will(returnValue(0.0));
    assertNotNull(cloned.getLabelAt(20, 20));
    assertNull(cloned.getLabelAt(-1.0, -2.0));
    assertTrue(cloned.getLabelAt(20.0, 20.0) != note.getLabelAt(20.0, 20.0));
    assertTrue(cloned.getLabelAt(20.0, 20.0).getSource() == cloned);
View Full Code Here

    elem.addModelElementListener((UmlModelElementListener)
      mockListener.proxy());
    elem.addModelElementListener((UmlModelElementListener)
      mockListener.proxy());
    // will be notified
    mockListener.expects(once()).method("elementChanged").with(eq(elem));
    elem.notifyElementChanged();
    // clone the element and make sure the listener is not invoked on the clone
    mockListener.expects(never()).method("elementChanged").with(eq(elem));
    MyModelElement clone = (MyModelElement) elem.clone();
    clone.notifyElementChanged();
View Full Code Here

      mockListener.proxy());
    // will be notified
    mockListener.expects(once()).method("elementChanged").with(eq(elem));
    elem.notifyElementChanged();
    // clone the element and make sure the listener is not invoked on the clone
    mockListener.expects(never()).method("elementChanged").with(eq(elem));
    MyModelElement clone = (MyModelElement) elem.clone();
    clone.notifyElementChanged();
    // remove the listener
    elem.removeModelElementListener((UmlModelElementListener)
      mockListener.proxy());
View Full Code Here

    MyModelElement clone = (MyModelElement) elem.clone();
    clone.notifyElementChanged();
    // remove the listener
    elem.removeModelElementListener((UmlModelElementListener)
      mockListener.proxy());
    mockListener.expects(never()).method("elementChanged").with(eq(elem));
    elem.notifyElementChanged();
  }
}
View Full Code Here

    assertEquals(bounds, connection.getAbsoluteBounds());

    assertNotNull(connection.toString());
    Mock mockRelation = mock(Relation.class);
    connection.setRelation((Relation) mockRelation.proxy());
    mockRelation.expects(once()).method("toString")
      .will(returnValue("relation"));
    assertEquals("relation", connection.toString());
   
    mockConnection.expects(once()).method("isVisible").with(eq(bounds))
      .will(returnValue(true));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.