org.mockcentral.editor.nodes.expectation_group
Class ExpectationGroupModel

java.lang.Object
  extended by org.mockcentral.editor.nodes.MockCentralNodeModel
      extended by org.mockcentral.editor.nodes.MockCentralGroupNodeModel
          extended by org.mockcentral.editor.nodes.expectation_group.ExpectationGroupModel
All Implemented Interfaces:
IMethodsListEditor

public class ExpectationGroupModel
extends MockCentralGroupNodeModel
implements IMethodsListEditor

A class that models the list of method expectations for a Mock Object definition.

Author:
David Hutchinson

Field Summary
 
Fields inherited from class org.mockcentral.editor.nodes.MockCentralGroupNodeModel
observers
 
Fields inherited from class org.mockcentral.editor.nodes.MockCentralNodeModel
element, node
 
Constructor Summary
ExpectationGroupModel(MockCentralNode node)
          Creates a new instance, casting and assigning the MockCentralNode reference.
 
Method Summary
 void addExpectation(java.lang.reflect.Method method)
          Creates a new ExpectationNode with default values using the supplied Method and adds it to the list of child nodes.
 void addExpectation(java.lang.String methodName)
          Creates a new ExpectationNode with default values using the supplied method name and adds it to the list of child nodes.
 ExpectationNode createExpectationNode(java.lang.String methodName)
          Creates and returns a new ExpectationNode constructed using the supplied method name.
 java.lang.String getChildNodeTypeDescription(boolean singular)
          Returns a String description of the MockCentralNode's child type, ie "Fixture", "Mock Object" etc.
 MockCentralTableModel<MockableMethod> getMethodNamesTableModel(java.lang.Class<?> clazz, boolean includeObjectMethods)
          Returns a MockCentralTableModel build from the supplied Class instance's methods.
 java.lang.String getMockObjectInterfaceClass()
          Returns the interface Class of the current Mock Object.
 java.lang.String getMockObjectName()
          Returns the name of the current Mock Obect.
 boolean isDefaultMethodVersionInUse(java.lang.reflect.Method method, boolean matchAnyParams)
          Returns whether the default version of a mocked method is already in use for the current Mock Object.
 boolean isDuplicateExpectation(org.jdom.Element e, int elementHashCode)
          Returns whether a new or edited Mock Object method expectation duplicates another in the list for the current Mock Object.
 boolean isInterfaceMethod(java.lang.String methodName, org.jdom.Element e)
          Returns whether the method defined by the parameters corresponds to one defined by the Mock Object interface.
 boolean isMethodNameInUse(java.lang.String methodName, java.lang.Object excluded)
          Returns whether the supplied method name is currently in use within the list of Mock Object method expectations.
 
Methods inherited from class org.mockcentral.editor.nodes.MockCentralGroupNodeModel
addChildNode, addObserver, editSelectedChild, fireChildrenChanged, getChildren, getElement, loadElementData, removeChildNode, sortChildren
 
Methods inherited from class org.mockcentral.editor.nodes.MockCentralNodeModel
addObserver, getEnclosingFixtureNode, getNode, getNotRemovableMessage, getObservers, registerChanges, removeObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpectationGroupModel

public ExpectationGroupModel(MockCentralNode node)
Creates a new instance, casting and assigning the MockCentralNode reference.

Parameters:
node - the MockCentralNode containing the jdom Element whose data this class models.
Method Detail

getChildNodeTypeDescription

public java.lang.String getChildNodeTypeDescription(boolean singular)
Description copied from class: MockCentralGroupNodeModel
Returns a String description of the MockCentralNode's child type, ie "Fixture", "Mock Object" etc.

Specified by:
getChildNodeTypeDescription in class MockCentralGroupNodeModel
Parameters:
singular - value for whether the String should be in singular form.
Returns:
a String description of the MockCentralNode type.

getMockObjectName

public java.lang.String getMockObjectName()
Returns the name of the current Mock Obect.

Returns:
the name of the current Mock Obect.

getMockObjectInterfaceClass

public java.lang.String getMockObjectInterfaceClass()
Returns the interface Class of the current Mock Object.

Returns:
the interface Class of the current Mock Object.

isInterfaceMethod

public boolean isInterfaceMethod(java.lang.String methodName,
                                 org.jdom.Element e)
Returns whether the method defined by the parameters corresponds to one defined by the Mock Object interface.

Parameters:
methodName - the method name.
e - the Element defining the method parameters (and other info).
Returns:
whether the method defined by the parameters corresponds to one defined by the Mock Object interface.

isDuplicateExpectation

public boolean isDuplicateExpectation(org.jdom.Element e,
                                      int elementHashCode)
Returns whether a new or edited Mock Object method expectation duplicates another in the list for the current Mock Object.

Parameters:
e - the JDOM Element containing the new or edited method expectation data.
elementHashCode - the hashcode to use to identify an instance to exclude from testing for duplication when it is being edited itself.
Returns:
whether an new or edited method expectation duplicates another in the list for the current Mock Object.

isDefaultMethodVersionInUse

public boolean isDefaultMethodVersionInUse(java.lang.reflect.Method method,
                                           boolean matchAnyParams)
Description copied from interface: IMethodsListEditor
Returns whether the default version of a mocked method is already in use for the current Mock Object. The default version is created from the method signature to assign default values to any parameters and return value.

Specified by:
isDefaultMethodVersionInUse in interface IMethodsListEditor
Parameters:
method - the Method to be mocked.
matchAnyParams - whether to match any parameters, i.e. return true if the method name is in use at all.
Returns:
whether the default version of a mocked method is already in use.

getMethodNamesTableModel

public MockCentralTableModel<MockableMethod> getMethodNamesTableModel(java.lang.Class<?> clazz,
                                                                      boolean includeObjectMethods)
Description copied from interface: IMethodsListEditor
Returns a MockCentralTableModel build from the supplied Class instance's methods. If the includeObjectMethods flag is set, this model will also include all java.lang.Object methods. The resulting table is populated with MockableMethod objects.

Specified by:
getMethodNamesTableModel in interface IMethodsListEditor
Parameters:
clazz - the Class.
includeObjectMethods - whether to include java.lang.Object methods.
Returns:
a MockCentralTableModel build from the supplied Class instance's methods.

isMethodNameInUse

public boolean isMethodNameInUse(java.lang.String methodName,
                                 java.lang.Object excluded)
Description copied from interface: IMethodsListEditor
Returns whether the supplied method name is currently in use within the list of Mock Object method expectations.

Specified by:
isMethodNameInUse in interface IMethodsListEditor
Parameters:
methodName - the method name.
excluded - an Object to exclude from duplication testing.
Returns:
whether the supplied method name is currently in use within the list of Mock Object method expectations.

addExpectation

public void addExpectation(java.lang.String methodName)
Creates a new ExpectationNode with default values using the supplied method name and adds it to the list of child nodes.

Parameters:
methodName - the name of the new Mock Object method.

addExpectation

public void addExpectation(java.lang.reflect.Method method)
Creates a new ExpectationNode with default values using the supplied Method and adds it to the list of child nodes.

Parameters:
method - the Mock Object Method.

createExpectationNode

public ExpectationNode createExpectationNode(java.lang.String methodName)
Creates and returns a new ExpectationNode constructed using the supplied method name.

Parameters:
methodName - the name for the new Mock Object method expectation defined by the node data.
Returns:
a new ExpectationNode constructed using the supplied method name.