package bluej.testmgr.record;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import bluej.pkgmgr.PkgMgrFrame;
| From an existing unit test we create an invoker record
| that represents all the existing fixture declarations
| and setup code.
|
| @author Andrew Patterson
|
public class ExistingFixtureInvokerRecord
extends InvokerRecord{
private List<String> fieldsSrc;
private String setUpSrc;
| Records a method call that returns a result to the user.
|
| @param returnType the Class of the return type of the method
| @param command the method statement to execute
|
public ExistingFixtureInvokerRecord()
{
fieldsSrc = new ArrayList<String>();
}
@Override
public boolean hasVoidResult()
{
return false;
}
public void addFieldDeclaration(String fieldDecl)
{
fieldsSrc.add(fieldDecl);
}
public void setSetupMethod(String setupMethodSrc)
{
setUpSrc = setupMethodSrc;
}
| Construct a declaration for any objects constructed
| by this invoker record.
|
| @return a String representing the object declaration
| src or null if there is none.
|
@Override
public String toFixtureDeclaration(String firstIndent)
{
StringBuffer sb = new StringBuffer();
ListIterator<String> it = fieldsSrc.listIterator();
while (it.hasNext()) {
String fieldDecl = (String) it.next();
sb.append(firstIndent);
sb.append(fieldDecl);
sb.append('\n');
}
return sb.toString();
}
| Construct a portion of an initialisation method for
| this invoker record.
|
| @return a String reprenting the object initialisation
| src or null if there is none.
|
@Override
public String toFixtureSetup(String secondIndent)
{
StringBuffer sb = new StringBuffer();
sb.append(secondIndent);
sb.append(setUpSrc);
sb.append('\n');
return sb.toString();
}
| Construct a portion of a test method for this
| invoker record.
|
| @return a String representing the test method src
|
@Override
public String toTestMethod(PkgMgrFrame pmf, String secondIndent)
{
return null;
}
@Override
public String toExpression()
{
throw new RuntimeException("Method not implemented for this type.");
}
}
top,
use,
map,
class ExistingFixtureInvokerRecord
. ExistingFixtureInvokerRecord
. hasVoidResult
. addFieldDeclaration
. setSetupMethod
. toFixtureDeclaration
. toFixtureSetup
. toTestMethod
. toExpression
97 neLoCode
+ 18 LoComm