Class TestValidator
- java.lang.Object
-
- org.proforma.util.TestValidator
-
- Direct Known Subclasses:
CheckstyleTestValidator
,CompileTestValidator
,HumanTestValidator
,JunitTestValidator
,PmdTestValidator
public abstract class TestValidator extends Object
An instance of this class validates a ProFormA test element. A grader can implement one subclass for each test-type, that can check the task and unzipped files with respect to the specific test.
E. g. a JUnit test driver is passed as part of a file element of the task. In the grading-hints section usually there are references to the test driver and its test methods. A subclass of the
TestValidator
class is used to check consistency between the grading-hints and the test driver source.In order to use a subclass with the
TestsValidationHelper
a client programm will have to register this class viaTestsValidationHelper.register(String, Class, int)
. Then when callingTestsValidationHelper.validate(Task, File, Path)
for each test the following calls will happen:preCheck()
once per test element instance of the represented test-type.- Then for each citation within the grading-hints section the method
checkSubRef(String)
andcheckNullifySubRef(String)
will be called once. This way a subclass may accumulate all sub-ref references in a private field. - Finally,
postCheck()
is called once per test element instance of the represented test-type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TestValidator.ExternalResourceResolver
protected static class
TestValidator.ResolvedFile
-
Field Summary
Fields Modifier and Type Field Description protected File
zipcontentdir
-
Constructor Summary
Constructors Modifier Constructor Description protected
TestValidator(String testId, Task task, File zipcontentdir, Path tmpDir)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
checkNullifySubRef(String subRef)
protected abstract void
checkSubRef(String subRef)
protected Map<ResourceCaster.ProformaTaskResourceref,TestValidator.ResolvedFile>
getResources(int min, int max, TestValidator.ExternalResourceResolver resolver)
protected Task
getTask()
protected Test
getTest()
protected Path
getTmpDir()
protected abstract void
postCheck()
protected abstract void
preCheck()
-
-
-
Field Detail
-
zipcontentdir
protected File zipcontentdir
-
-
Method Detail
-
getTest
protected Test getTest()
-
getTask
protected Task getTask()
-
getTmpDir
protected Path getTmpDir()
-
preCheck
protected abstract void preCheck() throws IllegalStateException
- Throws:
IllegalStateException
-
checkSubRef
protected abstract void checkSubRef(String subRef) throws IllegalStateException
- Throws:
IllegalStateException
-
checkNullifySubRef
protected abstract void checkNullifySubRef(String subRef) throws IllegalStateException
- Throws:
IllegalStateException
-
postCheck
protected abstract void postCheck() throws IllegalStateException
- Throws:
IllegalStateException
-
getResources
protected Map<ResourceCaster.ProformaTaskResourceref,TestValidator.ResolvedFile> getResources(int min, int max, TestValidator.ExternalResourceResolver resolver)
-
-