csheets.ext.test
Class TestableCell

java.lang.Object
  extended by csheets.ext.CellExtension
      extended by csheets.ext.test.TestableCell
All Implemented Interfaces:
Cell, CellListener, Extensible<Cell>, Serializable, Comparable<Cell>, EventListener

public class TestableCell
extends CellExtension

An extension of a cell in a spreadsheet, with support for test cases.

Author:
Staffan Gustafsson, Jens Schou, Einar Pehrson
See Also:
Serialized Form

Constructor Summary
TestableCell(Cell cell)
          Creates a testable cell extension for the given cell.
 
Method Summary
 void addTestableCellListener(TestableCellListener listener)
          Registers the given listener on the cell.
 TestCaseParam addTestCaseParam(Value value)
          Add a test case parameter to the cell's set of test case parameters.
 TestCaseParam addTestCaseParam(Value value, TestCaseParam.Type type)
          Add a test case parameter to the cell's set of test case parameters.
protected  boolean allPrecedentsHaveParams()
          Tests if all of the cells precedents have test case parameters.
 void cellCleared(Cell cell)
          Removes the test case parameters from the cell.
 void cellCopied(Cell cell, Cell source)
          Copies the user-specified test case parameters from the source cell to this one.
 void contentChanged(Cell cell)
          Invoked to indicate that the content of the cell in the spreadsheet was modified and that test cases and test case paremeters that depend on that data must be updated, and new ones generated.
protected  void extendTestCases(TestableCell firstPrec, TestCaseParam param)
           
protected  void fireTestCaseParametersChanged()
          Notifies all registered listeners that the cell's test case parameters changed.
protected  void fireTestCasesChanged()
          Notifies all registered listeners that the cell's test cases changed.
 Set<TestCaseParam> getTestCaseParams()
          Returns the cell's test case parameters.
 Set<TestCase> getTestCases()
          Returns the test cases for the cell, which consist of a predetermined value for each of the cell's precedents.
 double getTestedness()
          Returns the testedness of the cell, i.e. the ratio of valid test cases to available test cases in the cell.
 boolean hasTestCaseParams()
          Returns whether the cell has any test case parameters.
 boolean hasTestCases()
          Returns whether the cell has any test cases.
 boolean hasTestError()
          Returns whether any of the cell's test cases have been rejected.
 void precedentAddedParam(TestableCell cell, TestCaseParam param)
          Invoked when a test case parameter is added to one of the cell's precedents.
 void precedentRemovedParam(TestableCell cell, TestCaseParam param)
          Invoked when a test case parameter is removed from one of the cell's precedents.
protected  void removeAllTcpsOfType(TestCaseParam.Type type)
           
 void removeTestableCellListener(TestableCellListener listener)
          Removes the given listener from the cell.
 void removeTestCaseParam(TestCaseParam param)
          Removes a test case parameter from the cell's set of test case parameters.
 void removeTestCaseParam(TestCaseParam param, TestCaseParam.Type type)
          Removes a test case parameter from the cell's set of test case parameters.
 void resetTestCases()
          Generates new test cases for the cell, provided that all its precedents have test case parameters.
 
Methods inherited from class csheets.ext.CellExtension
addCellListener, clear, compareTo, copyFrom, dependentsChanged, getAddress, getCellListeners, getContent, getDelegate, getDependents, getExtension, getFormula, getName, getPrecedents, getSpreadsheet, getValue, moveFrom, removeCellListener, setContent, toString, valueChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestableCell

TestableCell(Cell cell)
Creates a testable cell extension for the given cell.

Parameters:
cell - the cell to extend
Method Detail

contentChanged

public void contentChanged(Cell cell)
Invoked to indicate that the content of the cell in the spreadsheet was modified and that test cases and test case paremeters that depend on that data must be updated, and new ones generated.

Specified by:
contentChanged in interface CellListener
Overrides:
contentChanged in class CellExtension
Parameters:
cell - the cell that was modified

getTestCases

public Set<TestCase> getTestCases()
Returns the test cases for the cell, which consist of a predetermined value for each of the cell's precedents.

Returns:
the cell's test cases

hasTestCases

public boolean hasTestCases()
Returns whether the cell has any test cases.

Returns:
true if the cell has any test cases

hasTestError

public boolean hasTestError()
Returns whether any of the cell's test cases have been rejected.

Returns:
true if any of the cell's test cases have been rejected

getTestedness

public double getTestedness()
Returns the testedness of the cell, i.e. the ratio of valid test cases to available test cases in the cell.

Returns:
a number between 0.0 and 1.0 denoting the level of testedness

resetTestCases

public void resetTestCases()
Generates new test cases for the cell, provided that all its precedents have test case parameters.


extendTestCases

protected void extendTestCases(TestableCell firstPrec,
                               TestCaseParam param)

getTestCaseParams

public Set<TestCaseParam> getTestCaseParams()
Returns the cell's test case parameters.

Returns:
the cell's the test case parameters.

hasTestCaseParams

public boolean hasTestCaseParams()
Returns whether the cell has any test case parameters.

Returns:
true if the cell has any test case parameters

allPrecedentsHaveParams

protected boolean allPrecedentsHaveParams()
Tests if all of the cells precedents have test case parameters.

Returns:
true if all of the cells precedents have test case parameters

addTestCaseParam

public TestCaseParam addTestCaseParam(Value value)
                               throws DuplicateUserTCPException
Add a test case parameter to the cell's set of test case parameters. On addition, the cell's dependents are notified.

Parameters:
value - the value of the test case parameter to be added
Returns:
the parameter that was added, or null if the cell already had an identical parameter
Throws:
DuplicateUserTCPException

addTestCaseParam

public TestCaseParam addTestCaseParam(Value value,
                                      TestCaseParam.Type type)
Add a test case parameter to the cell's set of test case parameters. On addition, the cell's dependents are notified.

Parameters:
value - the value of the test case parameter to be added
type - the type of test case parameter

removeTestCaseParam

public void removeTestCaseParam(TestCaseParam param)
Removes a test case parameter from the cell's set of test case parameters. On removal, the cell's dependents are notified.

Parameters:
param - the test case parameter to be removed

removeTestCaseParam

public void removeTestCaseParam(TestCaseParam param,
                                TestCaseParam.Type type)
Removes a test case parameter from the cell's set of test case parameters. On removal, the cell's dependents are notified.

Parameters:
param - the test case parameter to be removed
type - the type of the parameter to remove

removeAllTcpsOfType

protected void removeAllTcpsOfType(TestCaseParam.Type type)

precedentAddedParam

public void precedentAddedParam(TestableCell cell,
                                TestCaseParam param)
Invoked when a test case parameter is added to one of the cell's precedents. This causes the cell's test cases to be updated.

Parameters:
cell - the precedent to which the test case parameter was added
param - the test case parameter that was added

precedentRemovedParam

public void precedentRemovedParam(TestableCell cell,
                                  TestCaseParam param)
Invoked when a test case parameter is removed from one of the cell's precedents. This causes the cell's test cases to be updated.

Parameters:
cell - the precedent from which the test case parameter was removed
param - the test case parameter that was removed

cellCleared

public void cellCleared(Cell cell)
Removes the test case parameters from the cell.

Specified by:
cellCleared in interface CellListener
Overrides:
cellCleared in class CellExtension
Parameters:
cell - the cell that was modified

cellCopied

public void cellCopied(Cell cell,
                       Cell source)
Copies the user-specified test case parameters from the source cell to this one.

Specified by:
cellCopied in interface CellListener
Overrides:
cellCopied in class CellExtension
Parameters:
cell - the cell that was modified
source - the cell from which data was copied

addTestableCellListener

public void addTestableCellListener(TestableCellListener listener)
Registers the given listener on the cell.

Parameters:
listener - the listener to be added

removeTestableCellListener

public void removeTestableCellListener(TestableCellListener listener)
Removes the given listener from the cell.

Parameters:
listener - the listener to be removed

fireTestCasesChanged

protected void fireTestCasesChanged()
Notifies all registered listeners that the cell's test cases changed.


fireTestCaseParametersChanged

protected void fireTestCaseParametersChanged()
Notifies all registered listeners that the cell's test case parameters changed.