org.mockcentral.editor.nodes.mockobject
Class MockObjectModel

java.lang.Object
  extended by org.mockcentral.editor.nodes.MockCentralNodeModel
      extended by org.mockcentral.editor.nodes.mockobject.MockObjectModel

public class MockObjectModel
extends MockCentralNodeModel

A class that models a Mock Object defined in the jdom Element of a MockObjectNode object.

Author:
David Hutchinson

Field Summary
 
Fields inherited from class org.mockcentral.editor.nodes.MockCentralNodeModel
element, node, observers
 
Constructor Summary
MockObjectModel(MockObjectNode node)
          Assigns the MockCentralNode.
 
Method Summary
 void addObserver(IMockObjectModelObserver observer)
          Adds an IMockObjectModelObserver instance to the observers list.
 void editExpectations()
          Activates the ExpectationGroupNode for this Mock Object.
 java.lang.String getDefaultNewJndiName()
          Returns a default value for the JNDI name which will be unique within the Fixture.
 java.lang.String getJndiName()
          Returns the current value for the name under which the Mock Object will be bound in the testing Context, if any.
 java.lang.String getMockObjectInterface()
          Returns the current value for the mocked interface class name.
 java.lang.String getMockObjectName()
          Returns the current Mock Object name value.
 java.lang.String getNotRemovableMessage()
          Returns a message for display indicating why the corresposing MockCentralNode instance cannot be deleted, or null (as this default implementation does).
 boolean hasReferenceTo(java.lang.String mockObjectName)
          Returns whether the modeled Mock Object has a reference (within a method parameter or method result) to the one identified by the parameter.
 void loadElementData(boolean refreshUI)
          Loads the data from the JDOM Element provided by the MockCentralNode into the model.
 void setJndiName(java.lang.String jndiName)
          Sets the JNDI name value.
 void setMockObjectInterface(java.lang.String mockObjectInterface)
          Sets the Mock Object interface Class name.
 void setMockObjectName(java.lang.String mockObjectName, boolean updateReferences)
          Sets the Mock Object name.
 void updateMockObjectReference(java.lang.String oldName, java.lang.String newName)
          Updates the value for the name of a Mock Object referenced within this one's method expectations.
 
Methods inherited from class org.mockcentral.editor.nodes.MockCentralNodeModel
addObserver, getElement, getEnclosingFixtureNode, getNode, getObservers, registerChanges, removeObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockObjectModel

public MockObjectModel(MockObjectNode node)
Assigns the MockCentralNode.

Parameters:
node - the MockCentralNode containing the jdom element whose data this class models.
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.

addObserver

public void addObserver(IMockObjectModelObserver observer)
Adds an IMockObjectModelObserver instance to the observers list.

Parameters:
observer - the ModelObserver instance to add.

hasReferenceTo

public boolean hasReferenceTo(java.lang.String mockObjectName)
Returns whether the modeled Mock Object has a reference (within a method parameter or method result) to the one identified by the parameter.

Parameters:
mockObjectName - the name of the Mock Object to look for a reference to.
Returns:
whether the modeled Mock Object has a reference (within a method parameter or method result) to the one identified by the parameter.

setMockObjectName

public void setMockObjectName(java.lang.String mockObjectName,
                              boolean updateReferences)
Sets the Mock Object name. This method also updates references to this Mock Object's name in any other Mock Object's method expectations that use the value to identify a parameter or result.

Parameters:
mockObjectName - the value for the Mock Object name.
updateReferences - whether to update references to the orignal Mock Object name within other Mock Objects' methods

updateMockObjectReference

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

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

getMockObjectName

public java.lang.String getMockObjectName()
Returns the current Mock Object name value.

Returns:
the current Mock Object name value.

setMockObjectInterface

public void setMockObjectInterface(java.lang.String mockObjectInterface)
Sets the Mock Object interface Class name.

Parameters:
mockObjectInterface - the value for the Mock Object interface Class name.

getMockObjectInterface

public java.lang.String getMockObjectInterface()
Returns the current value for the mocked interface class name.

Returns:
the current value for the mocked interface class name.

getDefaultNewJndiName

public java.lang.String getDefaultNewJndiName()
Returns a default value for the JNDI name which will be unique within the Fixture.

Returns:
a default value for the JNDI name.

setJndiName

public void setJndiName(java.lang.String jndiName)
Sets the JNDI name value.

Parameters:
jndiName - the value to set.

getJndiName

public java.lang.String getJndiName()
Returns the current value for the name under which the Mock Object will be bound in the testing Context, if any.

Returns:
the current value for the name under which the Mock Object will be bound in the testing Context, if any.

editExpectations

public void editExpectations()
Activates the ExpectationGroupNode for this Mock Object.


getNotRemovableMessage

public java.lang.String getNotRemovableMessage()
Description copied from class: MockCentralNodeModel
Returns a message for display indicating why the corresposing MockCentralNode instance cannot be deleted, or null (as this default implementation does).

Overrides:
getNotRemovableMessage in class MockCentralNodeModel
Returns:
a message for display indicating why the corresposing MockCentralNode instance cannot be deleted, or null.