Interface AssessmentResultBuilder
-
- All Known Implementing Classes:
DefaultAssessmentResultBuilder
public interface AssessmentResultBuilderImplementations of this interface can be used to build anAssessmentResultsbased on results reported to the builder during an assessment. AnAssessmentResultBuilderis used by the variousAssessmentimplementations to track a collection ofTestResultinstances generated during the assessment process. new TestResult instances can be registered by calling theaddTestResult(Assessment, Document, String, TestResult)method. Once all assessments are completed, anAssessmentResultsinstance can be generated using thebuild(RequirementsManager)method. Before calling theDefaultAssessmentResultBuilder.build(RequirementsManager), callers must first call theDefaultAssessmentResultBuilder.end()method to designate the end of the assessment run.This interface supports marking specific derived requirements as tested by calling the
assignTestStatus(Assessment, Document, String, TestState)method. This can be useful to ensure that the derived requirementResultStatusdoes not get evaluated asResultStatus.NOT_TESTEDwhen a TestResult has not been generated for the derived requirement because there was no failure to report using theaddTestResult(Assessment, Document, String, TestResult)method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AssessmentResultBuilderaddAssessmentTarget(Document document)Allows the target of an assessment to be registered and tracked.<DOC extends Document>
AssessmentResultBuilderaddTestResult(Assessment<? extends DOC> assessment, DOC document, String derivedRequirementId, TestResult result)Appends a newTestResultto the collection of test results associated with the provided derived requirement identifier.AssessmentResultBuilderassignProperty(String key, String value)Allows arbitrary assessment properties to be associated with the results.<DOC extends Document>
AssessmentResultBuilderassignTestStatus(Assessment<? extends DOC> assessment, DOC document, String derivedRequirementId, TestState state)Marks the derived requirement associated with the provided identifier as having a specific TestState.AssessmentResultsbuild(RequirementsManager requirementsManager)Generates a newAssessmentResultsinstance based on the previously recordedTestResultrecords and other statuses provided to the builder..AssessmentResultBuilderend()Calling this method signals the end of the assessment.LoggingHandlergetLoggingHandler()Retrieves a handler that is used to process various assessment event callback methods.Map<String,TestState>getTestStateByDerivedRequirementId()Retrieves the mapping of derived requirement identifiers toTestState.voidsetLoggingHandler(LoggingHandler handler)AssessmentResultBuilderstart()Calling this method signals the start of the assessment.
-
-
-
Method Detail
-
getTestStateByDerivedRequirementId
Map<String,TestState> getTestStateByDerivedRequirementId()
Retrieves the mapping of derived requirement identifiers toTestState. To be tested the derived requirement must: 1) have an associatedTestResultprovided by calling theaddTestResult(Assessment, Document, String, TestResult)method, or 2) be declared as a specificTestStateby calling theassignTestStatus(Assessment, Document, String, TestState)method.- Returns:
- a map of derived requirement identifiers to the corresponding test status
-
start
AssessmentResultBuilder start()
Calling this method signals the start of the assessment. The assessment will be automatically started the first time eitheraddTestResult(Assessment, Document, String, TestResult)orassignTestStatus(Assessment, Document, String, TestState)is called. Multiple calls to this method will not change the start time from the initial time.- Returns:
- the same builder instance
-
end
AssessmentResultBuilder end()
Calling this method signals the end of the assessment.- Returns:
- the same builder instance
-
addAssessmentTarget
AssessmentResultBuilder addAssessmentTarget(Document document)
Allows the target of an assessment to be registered and tracked. This can be called multiple times for the same target without causing duplicate targets to be registered. It is expected that anAssessmentwill call this method at least once.- Parameters:
document- the target of the assessment- Returns:
- the same builder instance
-
assignProperty
AssessmentResultBuilder assignProperty(String key, String value)
Allows arbitrary assessment properties to be associated with the results. This can be used to include meta information in the assessment results produced.- Parameters:
key- the property keyvalue- the property value- Returns:
- this builder
-
addTestResult
<DOC extends Document> AssessmentResultBuilder addTestResult(Assessment<? extends DOC> assessment, DOC document, String derivedRequirementId, TestResult result)
Appends a newTestResultto the collection of test results associated with the provided derived requirement identifier.- Type Parameters:
DOC- the type of document that is the target of the assessment- Parameters:
assessment- the target assessmentdocument- the document being assessedderivedRequirementId- the derived requirement that the test result is associated withresult- the test result to append- Returns:
- the same builder instance
-
assignTestStatus
<DOC extends Document> AssessmentResultBuilder assignTestStatus(Assessment<? extends DOC> assessment, DOC document, String derivedRequirementId, TestState state)
Marks the derived requirement associated with the provided identifier as having a specific TestState. This method is called when theaddTestResult(Assessment, Document, String, TestResult)method is called. If no test result is reported for a given derived requirement, then this method needs to be called to indicate the actual test state of a derived requirement.- Type Parameters:
DOC- the type of document that is the target of the assessment- Parameters:
assessment- the target assessmentdocument- the document being assessedderivedRequirementId- the derived requirement to set the state forstate- the state to assign- Returns:
- the current builder instance
-
build
AssessmentResults build(RequirementsManager requirementsManager)
Generates a newAssessmentResultsinstance based on the previously recordedTestResultrecords and other statuses provided to the builder..Note:
end()must be called before this method to terminate the assessment.- Parameters:
requirementsManager- the set of requirements corresponding to the assessments performed- Returns:
- a new assessment result instance
- Throws:
IllegalStateException- if theend()method hasn't first been called
-
getLoggingHandler
LoggingHandler getLoggingHandler()
Retrieves a handler that is used to process various assessment event callback methods.- Returns:
- a
non-nullhandler instance
-
setLoggingHandler
void setLoggingHandler(LoggingHandler handler)
-
-