org.mockcentral.editor.nodes.expectation
Class ExpectationModel

java.lang.Object
  extended by org.mockcentral.editor.nodes.MockCentralNodeModel
      extended by org.mockcentral.editor.nodes.expectation.ExpectationModel
All Implemented Interfaces:
INodeProblemParticipant

public class ExpectationModel
extends MockCentralNodeModel
implements INodeProblemParticipant

A class that models a Mock Object method expectation data defined in the JDOM Element of an ExpectationNode object.

Author:
David Hutchinson

Field Summary
 
Fields inherited from class org.mockcentral.editor.nodes.MockCentralNodeModel
element, node, observers
 
Constructor Summary
ExpectationModel(ExpectationNode node)
          Creates a new instance, assigning the MockCentralNode.
 
Method Summary
 void addParameter(int index, org.mockcentral.server.SignaturePartBean model)
          Adds the supplied SignaturePartBean to the list of modeled Mock Object method parameters.
 void deleteParameter(org.mockcentral.server.SignaturePartBean spb)
          Deletes the supplied SignaturePartBean from the list of modeled Mock Object method parameters.
 java.lang.String getMethodName()
          Returns the value for the Mock Object method name.
 java.lang.String getMethodType()
          Returns the value for the Mock Object method type.
 NodeProblem getNodeProblem(java.lang.Object o)
          Returns the stored NodeProblem associated with the supplied Object, if any.
 java.util.ArrayList<org.mockcentral.server.SignaturePartBean> getParametersList()
          Returns the ArrayList containing the list of models of the Mock Object method parameters.
 org.mockcentral.server.SignaturePartBean getResult()
          Returns the SignaturePartBean modeling the Mock Object method expectation result.
 boolean hasReferenceTo(java.lang.String mockObjectName, MockObjectGroupModel mockObjectGroupModel)
          Returns whether the method expectation modeled in this class makes reference (as a parameter or the result) to the Mock Object modeled by the supplied MockObjectGroupModel.
 boolean isAnyParameters()
          Returns whether the Mock Object method expectation will accept all/any parameters.
 void loadElementData(boolean refreshUI)
          Loads the data from the JDOM Element provided by the MockCentralNode into the model.
 void setAnyParameters(boolean any)
          Based on the argument, sets or clears the value for whether the Mock Object method expectation will accept all/any parameters.
 void setMethodName(java.lang.String methodName)
          Sets the Mock Object method name value and updates the JDOM Element.
 void setMethodType(java.lang.String methodType)
          Sets the Mock Object method type value and updates the JDOM Element.
 void setParameter(int index, org.mockcentral.server.SignaturePartBean spb)
          Sets the data for the indexed modeled method parameter to that contained in the SignaturePartBean argument.
 void setResult(org.mockcentral.server.SignaturePartBean result)
          Sets the Mock Object method result.
 void updateMockObjectReference(java.lang.String oldName, java.lang.String newName)
          Updates the value for the name of a Mock Object referenced within the method expectation.
 
Methods inherited from class org.mockcentral.editor.nodes.MockCentralNodeModel
addObserver, getElement, 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

ExpectationModel

public ExpectationModel(ExpectationNode node)
Creates a new instance, assigning the MockCentralNode.

Parameters:
node - the MockCentralNode associated with this model.
Method Detail

loadElementData

public void loadElementData(boolean refreshUI)
Description copied from class: MockCentralNodeModel
Loads the data from the JDOM Element provided by the MockCentralNode into the model.

Specified by:
loadElementData in class MockCentralNodeModel
Parameters:
refreshUI - whether to send notification to ui components to update the display.

hasReferenceTo

public boolean hasReferenceTo(java.lang.String mockObjectName,
                              MockObjectGroupModel mockObjectGroupModel)
Returns whether the method expectation modeled in this class makes reference (as a parameter or the result) to the Mock Object modeled by the supplied MockObjectGroupModel. This value is used to determine if removing that Mock Object defintion would break this expectation.

Parameters:
mockObjectName - the name of the Mock Object to look for a reference to.
mockObjectGroupModel - the MockObjectGroupModel, used to look up referenced Mock Objects other than the enclosing one (for looking for indirect, i.e second-hand, references).
Returns:
whether the method expectation modeled in this class makes reference (as a parameter or the result) to the Mock Object modeled by the supplied MockObjectGroupModel.

updateMockObjectReference

public void updateMockObjectReference(java.lang.String oldName,
                                      java.lang.String newName)
Updates the value for the name of a Mock Object referenced within the method expectation.

Parameters:
oldName - the old value for the name.
newName - the new value for the name.

setMethodName

public void setMethodName(java.lang.String methodName)
Sets the Mock Object method name value and updates the JDOM Element.

Parameters:
methodName - the value to set.

getMethodName

public java.lang.String getMethodName()
Returns the value for the Mock Object method name.

Returns:
the value for the Mock Object method name.

setMethodType

public void setMethodType(java.lang.String methodType)
Sets the Mock Object method type value and updates the JDOM Element.

Parameters:
methodType - the value to set.

getMethodType

public java.lang.String getMethodType()
Returns the value for the Mock Object method type.

Returns:
the value for the Mock Object method type.

getParametersList

public java.util.ArrayList<org.mockcentral.server.SignaturePartBean> getParametersList()
Returns the ArrayList containing the list of models of the Mock Object method parameters.

Returns:
the ArrayList containing the list of models of the Mock Object method parameters.

addParameter

public void addParameter(int index,
                         org.mockcentral.server.SignaturePartBean model)
Adds the supplied SignaturePartBean to the list of modeled Mock Object method parameters.

Parameters:
index - the index at which to add the the supplied SignaturePartBean.
model - the SignaturePartBean to add to the modeled list of Mock Object method parameters.

deleteParameter

public void deleteParameter(org.mockcentral.server.SignaturePartBean spb)
Deletes the supplied SignaturePartBean from the list of modeled Mock Object method parameters.

Parameters:
spb - the SignaturePartBean to remove from the modeled list of Mock Object method parameters.

setParameter

public void setParameter(int index,
                         org.mockcentral.server.SignaturePartBean spb)
Sets the data for the indexed modeled method parameter to that contained in the SignaturePartBean argument.

Parameters:
index - the index of the modeled method paramter in the list.
spb - the SignaturePartBean containing the new parameter data.

setAnyParameters

public void setAnyParameters(boolean any)
Based on the argument, sets or clears the value for whether the Mock Object method expectation will accept all/any parameters. If true, clears the List containing the Mock Object method parameters, updates the JDOM Element by removing the parameter child Elements and adding a new anyParams child Element. This will result in an AnyConstraintMatcher being created for the Mock Object method expectation at runtime. If false, removes the Element 's anyParams child.

Parameters:
any - whether all/any parameters will be accepted.

isAnyParameters

public boolean isAnyParameters()
Returns whether the Mock Object method expectation will accept all/any parameters.

Returns:
whether the Mock Object method expectation will accept all/any parameters.

setResult

public void setResult(org.mockcentral.server.SignaturePartBean result)
Sets the Mock Object method result.

Parameters:
result - the SignaturePartBean modeling the Mock Object method result, or null if the result is to be void.

getResult

public org.mockcentral.server.SignaturePartBean getResult()
Returns the SignaturePartBean modeling the Mock Object method expectation result.

Returns:
the SignaturePartBean modeling the Mock Object method expectation result.

getNodeProblem

public NodeProblem getNodeProblem(java.lang.Object o)
Description copied from interface: INodeProblemParticipant
Returns the stored NodeProblem associated with the supplied Object, if any.

Specified by:
getNodeProblem in interface INodeProblemParticipant
Parameters:
o - the Object which may have an associated NodeProblem.
Returns:
the stored NodeProblem associated with the supplied Object, if any.