audiojury.action
Class TestManager

java.lang.Object
  |
  +--audiojury.action.TestManager

public class TestManager
extends java.lang.Object

Manages a collection of Tests within a Project.
The class implements the Singleton design pattern, which means there is only one instance of this class. This is necessary to make concurrent access to tests impossible.

See Also:
TestBuilder

Method Summary
 void cancelTest()
          Use this method to forget about the current Test (for undo operations).
 void deleteTest(java.lang.String name)
          Delets a Test in the current Project.
 void duplicateTest(java.lang.String name, java.lang.String newname)
          Duplicates a Test.
protected  ProjectBuilder getProjectBuilder()
          Gets the ProjectBuilder currently being used.
protected  TestBuilder getTestBuilder()
          Gets the TestBuilder currently being used.
 java.util.Hashtable getTests()
          Returns a hashtable of all Tests in the current project.
static TestManager getUniqueInstance()
          Enforces the Singleton design pattern by always returning the same instance of TestManager.
 void importTest(java.lang.String projname, Test test, java.lang.String newname)
          Imports a Test from another Project into the current project.
 boolean isUniqueTestName(java.lang.String name)
          Checks it a Test name is unique within the current Project.
 Test newTest(java.lang.String name)
          Creates a new Test.
 Test openTest(java.lang.String name)
          Opens a Test in the current Project and makes it current in the TestBuilder.
 void renameTest(java.lang.String name, java.lang.String newname)
          Renames a Test in the current Project.
 void saveTest()
          Saves the current Test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newTest

public Test newTest(java.lang.String name)
             throws NotUniqueNameException
Creates a new Test.

Parameters:
name - The desired name of the new Test.
Returns:
A new Test.
Throws:
NotUniqueNameException - if the proposed name is not unique.

openTest

public Test openTest(java.lang.String name)
              throws NoTestFoundException,
                     TestOperationException
Opens a Test in the current Project and makes it current in the TestBuilder.

Parameters:
name - The name of the Test to open.
Returns:
The opened Test.
Throws:
NoTestFoundException - if no test could be found with the specified name.
TestOperationException - if an unhandled error occurs.

cancelTest

public void cancelTest()
Use this method to forget about the current Test (for undo operations).
For example the administrator user has started to create a test, but then changes his mind and does not want to save the changes made and clicks cancel.


saveTest

public void saveTest()
Saves the current Test. Tests are not saved immediately to disk. Instead the save is postponed until the whole Project is saved.


deleteTest

public void deleteTest(java.lang.String name)
                throws NoTestFoundException
Delets a Test in the current Project.
Tests are not deleted immediately from disk. Instead the deletion is postponed until the whole project is saved. If the administrator user clicks "cancel" instead of "save project" the deletion will never take place.

Parameters:
name - The name of the test to delete.
Throws:
NoTestFoundException - if no test could be found with the specified name.

renameTest

public void renameTest(java.lang.String name,
                       java.lang.String newname)
                throws NotUniqueNameException,
                       NoTestFoundException
Renames a Test in the current Project.

Parameters:
name - The current name of the Test.
newname - The new desired name of the Test.
Throws:
NotUniqueNameException - if the proposed name is not unique.
NoTestFoundException - if no test could be found with the specified name.

duplicateTest

public void duplicateTest(java.lang.String name,
                          java.lang.String newname)
                   throws NotUniqueNameException,
                          NoTestFoundException,
                          TestOperationException
Duplicates a Test.

Parameters:
name - The current name of the Test.
newname - The desired name of the new copy.
Throws:
NotUniqueNameException - if the proposed name is not unique.
NoTestFoundException - if no test could be found with the specified name.
TestOperationException - if an unhandled error occurs.

importTest

public void importTest(java.lang.String projname,
                       Test test,
                       java.lang.String newname)
                throws NotUniqueNameException,
                       TestOperationException
Imports a Test from another Project into the current project.

Parameters:
projname - The name of the Project to import from.
test - The Test within this Project to import.
newname - The desired name of the imported Test copy.
Throws:
NotUniqueNameException - if the proposed name is not unique.
TestOperationException - if an unhandled error occurs.

getTests

public java.util.Hashtable getTests()
Returns a hashtable of all Tests in the current project. The key in the hash is the name of the respective test.

Returns:
A hashtable of Tests.

isUniqueTestName

public boolean isUniqueTestName(java.lang.String name)
Checks it a Test name is unique within the current Project.

Parameters:
name - A name candidate.
Returns:
True if the test name has not been used, and therefore is unique. False otherwise.

getUniqueInstance

public static TestManager getUniqueInstance()
Enforces the Singleton design pattern by always returning the same instance of TestManager. This should be used instead of a constructor.

Returns:
A unique single TestManager insatance.

getProjectBuilder

protected ProjectBuilder getProjectBuilder()
Gets the ProjectBuilder currently being used.

Returns:
The unique instace of the used ProjectBuilder.

getTestBuilder

protected TestBuilder getTestBuilder()
Gets the TestBuilder currently being used.

Returns:
The unique instance of the used TestBuilder