Package org.jmock

Examples of org.jmock.Mock.expects()


    assertEquals(source, relation.getElement1());
    assertEquals(target, relation.getElement2());
   
    // toString()
    mockSource.expects(once()).method("getName").will(returnValue("source"));
    mockTarget.expects(once()).method("getName").will(returnValue("target"));
    assertEquals("source->target", relation.toString());
   
    // name overrides toString()
    relation.setName("association");
    assertEquals("association", relation.toString());
View Full Code Here


    Mock mockListener = mock(UmlModelElementListener.class);
    UmlClass umlclass = UmlClass.getInstance();
    UmlClass clonedClass = (UmlClass) UmlClass.getInstance().clone();
    clonedClass.addModelElementListener((UmlModelElementListener)
      mockListener.proxy());
    mockListener.expects(once()).method("elementChanged").with(eq(clonedClass));
    clonedClass.setAbstract(true);
    assertTrue(clonedClass.isAbstract());
    assertFalse(umlclass.isAbstract());
  }
 
View Full Code Here

      .with(eq(connection));
    connection.setNode1((Node) mockNode3.proxy());
   
    mockNode2.expects(once()).method("removeNodeChangeListener")
      .with(eq(connection));
    mockNode4.expects(once()).method("addNodeChangeListener")
      .with(eq(connection));
    connection.setNode2(null);
  }

  /**
 
View Full Code Here

    List<UmlProperty> methodList = new ArrayList<UmlProperty>();
    methodList.add(new UmlProperty("method1"));
    methodList.add(new UmlProperty("method2"));
    methodList.add(new UmlProperty("method3"));
   
    mockListener.expects(once()).method("elementChanged").with(eq(clonedClass));
    clonedClass.setMethods(methodList);
    assertEquals(methodList, clonedClass.getMethods());
  }

  /**
 
View Full Code Here

    mockNode2.expects(once()).method("calculateIntersection");
   
    // draw dashed
    connection.invalidate();
    connection.setIsDashed(true);
    mockDrawingContext.expects(once()).method("drawDashedLine");
    connection.draw((DrawingContext) mockDrawingContext.proxy());
    // draw non-dashed
    connection.setIsDashed(false);
    mockDrawingContext.expects(once()).method("drawLine");
    connection.draw((DrawingContext) mockDrawingContext.proxy());
View Full Code Here

    connection.setIsDashed(true);
    mockDrawingContext.expects(once()).method("drawDashedLine");
    connection.draw((DrawingContext) mockDrawingContext.proxy());
    // draw non-dashed
    connection.setIsDashed(false);
    mockDrawingContext.expects(once()).method("drawLine");
    connection.draw((DrawingContext) mockDrawingContext.proxy());
    assertTrue(connection.isValid());
  }

  /**
 
View Full Code Here

    List<UmlProperty> attributeList = new ArrayList<UmlProperty>();
    attributeList.add(new UmlProperty("attrib1"));
    attributeList.add(new UmlProperty("attrib2"));
    attributeList.add(new UmlProperty("attrib3"));
   
    mockListener.expects(once()).method("elementChanged").with(eq(clonedClass));
    clonedClass.setAttributes(attributeList);
    assertEquals(attributeList, clonedClass.getAttributes());
  }

  /**
 
View Full Code Here

  public void testReset() {
    Mock mockCommand2 = mock(Command.class);
    Command command2 = (Command) mockCommand2.proxy();
   
    mockCommand.expects(once()).method("run");
    mockCommand2.expects(once()).method("run");
    mockCommand2.expects(once()).method("undo");
   
    commandProcessor.execute(command);
    commandProcessor.execute(command2);
    commandProcessor.undo();
View Full Code Here

   */
  public void testReassignNodes() {
    Mock mockNode1a = mock(Node.class), mockNode2a = mock(Node.class);
    mockNode1.expects(once()).method("removeNodeChangeListener")
      .with(eq(connection));
    mockNode1a.expects(once()).method("addNodeChangeListener")
      .with(eq(connection));
    connection.setNode1((Node) mockNode1a.proxy());
   
    mockNode2.expects(once()).method("removeNodeChangeListener")
      .with(eq(connection));
View Full Code Here

    List<UmlStereotype> stereotypeList = new ArrayList<UmlStereotype>();
    stereotypeList.add(new UmlStereotype("stereo1"));
    stereotypeList.add(new UmlStereotype("stereo2"));
    stereotypeList.add(new UmlStereotype("stereo3"));
   
    mockListener.expects(once()).method("elementChanged").with(eq(clonedClass));
    clonedClass.setStereotypes(stereotypeList);
    assertEquals(stereotypeList, clonedClass.getStereotypes());
  }
}
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.